public class Arithmetic
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
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.
|
public static int roundUp(double x)
x - a value.x rounded uppublic static int roundDown(double x)
x - a valuex 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 retainx but with a
limited apparent precisionroundDecimal(PI,2) = 3.14fpublic static int abs(int x)
x - the argument whose absolute value is to be determinedpublic static double abs(double x)
x - the argument whose absolute value is to be determinedpublic 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 argumenta and bpublic 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 argumenta and bCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.