public final class Fortran
extends java.lang.Object
Fortran
supplements the standard Math
class with methods that mimic selected
Fortran 90 functions. Overloads for various numeric types are provided to avoid type casting.Modifier and Type | Method and Description |
---|---|
static double |
aint(double n)
Returns the whole
Double number nearest the specified number, rounded towards zero. |
static float |
aint(float n)
Returns the whole
Float number nearest the specified number, rounded towards zero. |
static double |
anint(double n)
Returns the
Double number nearest the specified number, using standard rounding. |
static float |
anint(float n)
Returns the
Float number nearest the specified number, using standard rounding. |
static int |
ceiling(double n)
Returns the
Integer nearest the specified Double number,
rounded towards positive infinity. |
static int |
ceiling(float n)
Returns the
Integer nearest the specified Float number,
rounded towards positive infinity. |
static int |
floor(double n)
Returns the
Integer nearest the specified Double number,
rounded towards negative infinity. |
static int |
floor(float n)
Returns the
Integer nearest the specified Float number,
rounded towards negative infinity. |
static long |
knint(double n)
Returns the
Long number nearest the specified Double , using standard rounding. |
static long |
knint(float n)
Returns the
Long number nearest the specified Float , using standard rounding. |
static double |
max(double... args)
Returns the largest of the specified
Double numbers. |
static float |
max(float... args)
Returns the largest of the specified
Float numbers. |
static int |
max(int... args)
Returns the largest of the specified
Integer numbers. |
static long |
max(long... args)
Returns the largest of the specified
Long numbers. |
static double |
min(double... args)
Returns the smallest of the specified
Double numbers. |
static float |
min(float... args)
Returns the smallest of the specified
Float numbers. |
static int |
min(int... args)
Returns the smallest of the specified
Integer numbers. |
static long |
min(long... args)
Returns the smallest of the specified
Long numbers. |
static double |
modulo(double a,
double p)
Returns the first
Double number modulo the second number. |
static float |
modulo(float a,
float p)
Returns the first
Float number modulo the second number. |
static int |
modulo(int a,
int p)
Returns the first
Integer number modulo the second number. |
static long |
modulo(long a,
long p)
Returns the first
Long number modulo the second number. |
static int |
nint(double n)
Returns the
Integer number nearest the specified Double , using standard rounding. |
static int |
nint(float n)
Returns the
Integer number nearest the specified Float , using standard rounding. |
static double |
sum(double... args)
Returns the sum of the specified
Double numbers. |
static float |
sum(float... args)
Returns the sum of the specified
Float numbers. |
static int |
sum(int... args)
Returns the sum of the specified
Integer numbers. |
static long |
sum(long... args)
Returns the sum of the specified
Long numbers. |
public static double aint(double n)
Double
number nearest the specified number, rounded towards zero.
Returns the result of the standard method Math.floor(double)
or Math.ceil(double)
,
depending on the sign of n
.n
- the Double
number to roundDouble
number nearest n
whose
absolute value is less than or equal to n
public static float aint(float n)
Float
number nearest the specified number, rounded towards zero.
Returns the result of the standard method Math.floor(double)
or Math.ceil(double)
,
depending on the sign of n
.n
- the Float
number to roundFloat
number nearest n
whose
absolute value is less than or equal to n
public static double anint(double n)
Double
number nearest the specified number, using standard rounding.
Always rounds numbers midway between two integral values away from zero.n
- the Double
number to roundDouble
number nearest to n
public static float anint(float n)
Float
number nearest the specified number, using standard rounding.
Always rounds numbers midway between two integral values away from zero.n
- the Float
number to roundFloat
number nearest to n
public static int ceiling(double n)
Integer
nearest the specified Double
number,
rounded towards positive infinity.
Returns the result of the standard Math.ceil(double)
method, cast to Integer
.n
- the Double
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static int ceiling(float n)
Integer
nearest the specified Float
number,
rounded towards positive infinity.
Returns the result of the standard Math.ceil(double)
method, cast to Integer
.n
- the Float
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static int floor(double n)
Integer
nearest the specified Double
number,
rounded towards negative infinity.
Returns the result of the standard Math.floor(double)
method, cast to Integer
.n
- the Double
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static int floor(float n)
Integer
nearest the specified Float
number,
rounded towards negative infinity.
Returns the result of the standard Math.floor(double)
method, cast to Integer
.n
- the Float
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static long knint(double n)
Long
number nearest the specified Double
, using standard rounding.
Equivalent to casting the result of anint(double)
to Long
.n
- the Double
number to roundLong
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Long
public static long knint(float n)
Long
number nearest the specified Float
, using standard rounding.
Equivalent to casting the result of anint(float)
to Long
.n
- the Float
number to roundLong
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Long
public static double max(double... args)
Double
numbers.
Returns Double.MIN_VALUE
if no arguments are supplied.args
- the Double
numbers to compare with each other.Double
number found among args
java.lang.NullPointerException
- if args
is null
public static float max(float... args)
Float
numbers.
Returns Float.MIN_VALUE
if no arguments are supplied.args
- the Float
numbers to compare with each other.Float
number found among args
java.lang.NullPointerException
- if args
is null
public static int max(int... args)
Integer
numbers.
Returns Integer.MIN_VALUE
if no arguments are supplied.args
- the Integer
numbers to compare with each other.Integer
number found among args
java.lang.NullPointerException
- if args
is null
public static long max(long... args)
Long
numbers.
Returns Long.MIN_VALUE
if no arguments are supplied.args
- the Long
numbers to compare with each other.Long
number found among args
java.lang.NullPointerException
- if args
is null
public static double min(double... args)
Double
numbers.
Returns Double.MAX_VALUE
if no arguments are supplied.args
- the Double
numbers to compare with each other.Double
number found among args
java.lang.NullPointerException
- if args
is null
public static float min(float... args)
Float
numbers.
Returns Float.MAX_VALUE
if no arguments are supplied.args
- the Float
numbers to compare with each other.Float
number found among args
java.lang.NullPointerException
- if args
is null
public static int min(int... args)
Integer
numbers.
Returns Integer.MAX_VALUE
if no arguments are supplied.args
- the Integer
numbers to compare with each other.Integer
number found among args
java.lang.NullPointerException
- if args
is null
public static long min(long... args)
Long
numbers.
Returns Long.MAX_VALUE
if no arguments are supplied.args
- the Long
numbers to compare with each other.Long
number found among args
java.lang.NullPointerException
- if args
is null
public static double modulo(double a, double p)
Double
number modulo the second number.
Provides the Double
equivalent of the standard Math.floorMod(int, int)
method.
See there for details.a
- the Double
number indicating the dividendp
- the Double
number indicating the divisorDouble
number that equals a
modulo p
java.lang.ArithmeticException
- if p
is zero or the intermediate floor(double)
result overflows Integer
public static float modulo(float a, float p)
Float
number modulo the second number.
Provides the Float
equivalent of the standard Math.floorMod(int, int)
method.
See there for details.a
- the Float
number indicating the dividendp
- the Float
number indicating the divisorFloat
number that equals a
modulo p
java.lang.ArithmeticException
- if p
is zero or the intermediate floor(float)
result overflows Integer
public static int modulo(int a, int p)
Integer
number modulo the second number.
Returns the result of the standard Math.floorMod(int, int)
method. See there for details.a
- the Integer
number indicating the dividendp
- the Integer
number indicating the divisorInteger
number that equals a
modulo p
java.lang.ArithmeticException
- if p
is zeropublic static long modulo(long a, long p)
Long
number modulo the second number.
Returns the result of the standard Math.floorMod(int, int)
method. See there for details.a
- the Long
number indicating the dividendp
- the Long
number indicating the divisorLong
number that equals a
modulo p
java.lang.ArithmeticException
- if p
is zeropublic static int nint(double n)
Integer
number nearest the specified Double
, using standard rounding.
Equivalent to casting the result of anint(double)
to Integer
.n
- the Double
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static int nint(float n)
Integer
number nearest the specified Float
, using standard rounding.
Equivalent to casting the result of anint(float)
to Integer
.n
- the Float
number to roundInteger
number nearest to n
java.lang.ArithmeticException
- if the rounded result overflows Integer
public static double sum(double... args)
Double
numbers.
Returns zero if no arguments are supplied.args
- the Double
numbers to sum up.Double
number that is the sum of all args
java.lang.NullPointerException
- if args
is null
public static float sum(float... args)
Float
numbers.
Returns zero if no arguments are supplied.args
- the Float
numbers to sum up.Float
number that is the sum of all args
java.lang.NullPointerException
- if args
is null
public static int sum(int... args)
Integer
numbers.
Returns zero if no arguments are supplied.args
- the Integer
numbers to sum up.Integer
number that is the sum of all args
java.lang.ArithmeticException
- if the sum overflows Integer
at any pointjava.lang.NullPointerException
- if args
is null
public static long sum(long... args)
Long
numbers.
Returns zero if no arguments are supplied.args
- the Long
numbers to sum up.Long
number that is the sum of all args
java.lang.ArithmeticException
- if the sum overflows Long
at any pointjava.lang.NullPointerException
- if args
is null