Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class SafeMath extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
avg(int value1,
int value2)
Computes the average of two values without overflow or underflow.
|
static byte |
castByte(int value)
Casts int to byte, looking for any underflow or overflow.
|
static byte |
castByte(long value)
Casts long to byte, looking for any underflow or overflow.
|
static int |
castInt(long value)
Casts long to int, looking for any underflow or overflow.
|
static short |
castShort(int value)
Casts int to short, looking for any underflow or overflow.
|
static long |
multiply(long value1,
long value2)
Multiplies two longs, looking for any overflow.
|
public static byte castByte(int value)
throws ArithmeticException
ArithmeticException - for underflow or overflowpublic static byte castByte(long value)
throws ArithmeticException
ArithmeticException - for underflow or overflowpublic static short castShort(int value)
throws ArithmeticException
ArithmeticException - for underflow or overflowpublic static int castInt(long value)
throws ArithmeticException
ArithmeticException - for underflow or overflowpublic static long multiply(long value1,
long value2)
ArithmeticException - for overflowpublic static int avg(int value1,
int value2)
Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.