|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ttools.func.Arithmetic
public class Arithmetic
Standard arithmetic functions including things like rounding, sign manipulation, and maximum/minimum functions.
Method Summary | |
---|---|
static double |
abs(double x)
Returns the absolute value of a floating point value. |
static int |
abs(int x)
Returns the absolute value of an integer value. |
static int |
max(int a,
int b)
Returns the greater of two integer values. |
static double |
maxNaN(double a,
double b)
Returns the greater of two floating point values. |
static double |
maxReal(double a,
double b)
Returns the greater of two floating point values, ignoring blanks. |
static int |
min(int a,
int b)
Returns the smaller of two integer values. |
static double |
minNaN(double a,
double b)
Returns the smaller of two floating point values. |
static double |
minReal(double a,
double b)
Returns the smaller of two floating point values, ignoring blanks. |
static int |
round(double x)
Rounds a value to the nearest integer. |
static float |
roundDecimal(double x,
int dp)
Rounds a value to a given number of decimal places. |
static int |
roundDown(double x)
Rounds a value down to an integer value. |
static int |
roundUp(double x)
Rounds a value up to an integer value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int roundUp(double x)
x
- a value.
x
rounded uppublic static int roundDown(double x)
x
- a value
x
rounded downpublic static int round(double x)
x
- a floating point value.
x
rounded to the nearest integerpublic static float roundDecimal(double x, int dp)
float
(32-bit floating point value),
so this is only suitable for relatively low-precision values.
It's intended for truncating the number of apparent significant
figures represented by a value which you know has been obtained
by combining other values of limited precision.
For more control, see the functions in the Formats
class.
x
- a floating point valuedp
- number of decimal places (digits after the decimal point)
to retain
x
but with a
limited apparent precisionroundDecimal(PI,2) = 3.14f
public static int abs(int x)
x
- the argument whose absolute value is to be determined
public static double abs(double x)
x
- the argument whose absolute value is to be determined
public static int max(int a, int b)
Multiple-argument maximum functions are also provided in the
Arrays
and Lists
packages.
a
- an argument.b
- another argument.
a
and b
.public static double maxNaN(double a, double b)
a
- an argument.b
- another argument.
a
and b
.public static double maxReal(double a, double b)
Multiple-argument maximum functions are also provided in the
Arrays
and Lists
packages.
a
- an argumentb
- another argument
a
and b
public static int min(int a, int b)
Multiple-argument minimum functions are also provided in the
Arrays
and Lists
packages.
a
- an argument.b
- another argument.
a
and b
.public static double minNaN(double a, double b)
a
- an argument.b
- another argument.
a
and b
.public static double minReal(double a, double b)
Multiple-argument minimum functions are also provided in the
Arrays
and Lists
packages.
a
- an argumentb
- another argument
a
and b
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |