public final class MathUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BYTES_IN_DOUBLE |
static int |
BYTES_IN_INT |
static int |
BYTES_IN_LONG |
static int |
BYTES_IN_SHORT |
static BigDecimal |
CURRENCY_CENTS_PER_DOLLAR
The number of cents in a dollar.
|
static int |
CURRENCY_SCALE
The scale for currency numbers.
|
static BigDecimal |
CURRENCY0
A 0 currency.
|
static int |
INTEGER_SCALE
The scale for integer numbers.
|
static BigDecimal |
INTEGER0
A 0 integer.
|
static BigDecimal |
INTEGER1
A 1 integer.
|
static int |
PERCENT_SCALE
The scale for percent numbers.
|
static BigDecimal |
PERCENT0
A 0 percent.
|
static BigDecimal |
PERCENT100
A 1000 percent.
|
static double |
PI_OVER_2 |
static double |
PI_OVER_4 |
static double |
PI_TIMES_2 |
| Modifier and Type | Method and Description |
|---|---|
static BigDecimal |
add(BigDecimal left,
Number right) |
static <V extends Number> |
add(Number left,
Number right,
Class<V> resultClass) |
static void |
append(StringBuilder string,
double number) |
static double |
avg(double a,
double b) |
static double |
clamp(double x,
double min,
double max)
Clamps a double value to a given range.
|
static int |
clamp(int x,
int min,
int max)
Clamps an int value to a given range.
|
static String |
currencyToString(BigDecimal amount)
Convert a BigDecimal amount to a currency string prefixed by the "$" sign.
|
static double |
distance(double x1,
double y1,
double x2,
double y2)
Calculate the distance between two coordinates.
|
static BigDecimal |
divideCurrency(BigDecimal left,
BigDecimal right)
Divide two currency amounts, setting the scale to
CURRENCY_SCALE
and rounding 1/2 u |
static BigDecimal |
dividePercent(BigDecimal left,
BigDecimal right)
Divide two percent amounts, setting the scale to
CURRENCY_SCALE
and rounding 1/2 u |
static BigDecimal |
dividePercent(double left,
double right)
Divide two percent amounts, setting the scale to
CURRENCY_SCALE
and rounding 1/2 u |
static BigDecimal |
dividePercent(double left,
int right)
Divide two percent amounts, setting the scale to
CURRENCY_SCALE
and rounding 1/2 u |
static String |
format(String pattern,
Number number) |
static double |
getAngle(LineString points,
int i1,
int i2,
boolean start)
Code taken from DRA FME scripts to calculate angles.
|
static BigDecimal |
getBigDecimal(Object value) |
static BigDecimal |
getCurrency(BigDecimal amount)
Convert a BigDecimal amount into a currency BigDecimal.
|
static BigDecimal |
getCurrency(double amount)
Convert a double amount into a currency BigDecimal.
|
static BigDecimal |
getInteger(BigDecimal value)
Convert a BigDecimal into an ineteger BigDecimal.
|
static BigDecimal |
getInteger(int value)
Convert a int into an ineteger BigDecimal.
|
static Object |
getMaxValue(Class<?> dataType) |
static Object |
getMinValue(Class<?> dataType) |
static double |
getNorthClockwiseAngle(double angle) |
static BigDecimal |
getPercent(BigDecimal decimalPercent)
Convert a BigDecimal decimal percent (e.g.
|
static BigDecimal |
getPercent(double decimalPercent)
Convert a double decimal percent (e.g.
|
static BigDecimal |
getPercent(String decimalPercent)
Convert a String decimal percent (e.g.
|
static int |
hashCode(double d) |
static String |
integerToString(BigDecimal integer)
Convert a BigDecimal integer to a string.
|
static boolean |
isAcute(double x1,
double y1,
double x2,
double y2,
double x3,
double y3) |
static boolean |
isNanOrInfinite(double... values) |
static double |
makePrecise(double scale,
double value) |
static double |
max(double... values) |
static int |
max(int... values) |
static double |
max(Iterable<? extends Number> numbers) |
static int |
maxInt(Iterable<Integer> numbers) |
static double |
midpoint(double d1,
double d2) |
static double |
min(double... values) |
static int |
min(int... values) |
static double |
min(Iterable<? extends Number> numbers) |
static int |
minInt(Iterable<Integer> numbers) |
static double |
orientedAngleBetween(double angle1,
double angle2) |
static String |
percentToString(BigDecimal decimalPercent)
Convert a BigDecimal decimal percent to a percent string suffixed by the
"%" sign.
|
static String |
percentToString(BigDecimal decimalPercent,
int scale)
Convert a BigDecimal decimal percent to a percent string suffixed by the
"%" sign with the specified number of decimal places.
|
static double |
pointLineDistance(double x,
double y,
double x1,
double y1,
double x2,
double y2) |
static boolean |
precisionEqual(double value1,
double value2,
double scale) |
static double |
randomGaussian(double mean,
double variance) |
static double |
randomRange(double min,
double max) |
static byte |
sgn(byte x) |
static int |
sgn(double x) |
static int |
sgn(float x) |
static int |
sgn(int x) |
static int |
sgn(long x) |
static short |
sgn(short x) |
static <V extends Number> |
subtract(Number left,
Number right,
Class<V> resultClass) |
static Double |
toDouble(Object value) |
static double[] |
toDoubleArray(List<? extends Number> numbers) |
static double[] |
toDoubleArray(String... values) |
static double[] |
toDoubleArraySplit(String value) |
static double[] |
toDoubleArraySplit(String value,
String regex) |
static Double |
toDoubleValue(Object value) |
static int |
toInt(byte[] bytes,
int offset) |
static long |
toLong(byte[] bytes,
int offset) |
static String |
toString(BigDecimal number) |
static String |
toString(BigInteger number) |
static String |
toString(byte number) |
static String |
toString(double number) |
static String |
toString(double number,
int precision) |
static String |
toString(float number) |
static String |
toString(int number) |
static String |
toString(long number) |
static String |
toString(Number number) |
static String |
toString(short number) |
public static final int BYTES_IN_DOUBLE
public static final int BYTES_IN_INT
public static final int BYTES_IN_LONG
public static final int BYTES_IN_SHORT
public static final BigDecimal CURRENCY_CENTS_PER_DOLLAR
public static final int CURRENCY_SCALE
public static final BigDecimal CURRENCY0
public static final int INTEGER_SCALE
public static final BigDecimal INTEGER0
public static final BigDecimal INTEGER1
public static final int PERCENT_SCALE
public static final BigDecimal PERCENT0
public static final BigDecimal PERCENT100
public static final double PI_OVER_2
public static final double PI_OVER_4
public static final double PI_TIMES_2
public static BigDecimal add(BigDecimal left, Number right)
left - The left operand.right - The right operand.public static void append(StringBuilder string, double number)
public static double avg(double a,
double b)
public static double clamp(double x,
double min,
double max)
x - the value to clampmin - the minimum value of the rangemax - the maximum value of the rangepublic static int clamp(int x,
int min,
int max)
x - the value to clampmin - the minimum value of the rangemax - the maximum value of the rangepublic static String currencyToString(BigDecimal amount)
amount - The BigDecimal amount.public static double distance(double x1,
double y1,
double x2,
double y2)
x1 - The first x coordinate.y1 - The first y coordinate.x2 - The second x coordinate.y2 - The second y coordinate.public static BigDecimal divideCurrency(BigDecimal left, BigDecimal right)
CURRENCY_SCALE
and rounding 1/2 uleft - The left operand.right - The right operand.public static BigDecimal dividePercent(BigDecimal left, BigDecimal right)
CURRENCY_SCALE
and rounding 1/2 uleft - The left operand.right - The right operand.public static BigDecimal dividePercent(double left, double right)
CURRENCY_SCALE
and rounding 1/2 uleft - The left operand.right - The right operand.public static BigDecimal dividePercent(double left, int right)
CURRENCY_SCALE
and rounding 1/2 uleft - The left operand.right - The right operand.public static double getAngle(LineString points, int i1, int i2, boolean start)
points - i1 - i2 - public static BigDecimal getBigDecimal(Object value)
public static BigDecimal getCurrency(BigDecimal amount)
amount - The ammount.public static BigDecimal getCurrency(double amount)
amount - The ammount.public static BigDecimal getInteger(BigDecimal value)
value - The BigDecimal value.public static BigDecimal getInteger(int value)
value - The int value.public static double getNorthClockwiseAngle(double angle)
public static BigDecimal getPercent(BigDecimal decimalPercent)
decimalPercent - The decimal percent value.public static BigDecimal getPercent(double decimalPercent)
decimalPercent - The decimal percent value.public static BigDecimal getPercent(String decimalPercent)
decimalPercent - The decimal percent value.public static int hashCode(double d)
public static String integerToString(BigDecimal integer)
integer - The BigDecimal integer.public static boolean isAcute(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
public static boolean isNanOrInfinite(double... values)
public static double makePrecise(double scale,
double value)
public static double max(double... values)
public static int max(int... values)
public static double midpoint(double d1,
double d2)
public static double min(double... values)
public static int min(int... values)
public static double orientedAngleBetween(double angle1,
double angle2)
public static String percentToString(BigDecimal decimalPercent)
decimalPercent - The BigDecimal percent.public static String percentToString(BigDecimal decimalPercent, int scale)
decimalPercent - The BigDecimal percent.scale - The number of decimal places to show.public static double pointLineDistance(double x,
double y,
double x1,
double y1,
double x2,
double y2)
public static boolean precisionEqual(double value1,
double value2,
double scale)
public static double randomGaussian(double mean,
double variance)
public static double randomRange(double min,
double max)
public static byte sgn(byte x)
public static int sgn(double x)
public static int sgn(float x)
public static int sgn(int x)
public static int sgn(long x)
public static short sgn(short x)
public static <V extends Number> V subtract(Number left, Number right, Class<V> resultClass)
public static double[] toDoubleArray(String... values)
public static double[] toDoubleArraySplit(String value)
public static final int toInt(byte[] bytes,
int offset)
public static final long toLong(byte[] bytes,
int offset)
public static String toString(BigDecimal number)
public static String toString(BigInteger number)
public static String toString(byte number)
public static String toString(double number)
public static String toString(double number, int precision)
public static String toString(float number)
public static String toString(int number)
public static String toString(long number)
public static String toString(short number)
Copyright © 2015 Revolution Systems Inc.. All rights reserved.