Skip to content

Most visited

Recently visited

navigation
Added in API level 1

StrictMath

public final class StrictMath
extends Object

java.lang.Object
   ↳ java.lang.StrictMath


Class StrictMath provides basic math constants and operations such as trigonometric functions, hyperbolic functions, exponential, logarithms, etc.

In contrast to class Math, the methods in this class return exactly the same results on all platforms. Algorithms based on these methods thus behave the same (e.g. regarding numerical convergence) on all platforms, complying with the slogan "write once, run everywhere". On the other side, the implementation of class StrictMath may be less efficient than that of class Math, as class StrictMath cannot utilize platform specific features such as an extended precision math co-processors.

The methods in this class are specified using the "Freely Distributable Math Library" (fdlibm), version 5.3.

http://www.netlib.org/fdlibm/

Summary

Constants

double E

The double value closest to e, the base of the natural logarithm.

double PI

The double value closest to pi, the ratio of a circle's circumference to its diameter.

Public methods

static double IEEEremainder(double x, double y)

Returns the remainder of dividing x by y using the IEEE 754 rules.

static double abs(double d)

Returns the absolute value of the argument.

static long abs(long l)

Returns the absolute value of the argument.

static float abs(float f)

Returns the absolute value of the argument.

static int abs(int i)

Returns the absolute value of the argument.

static double acos(double x)

Returns the closest double approximation of the arc cosine of the argument within the range [0..pi].

static double asin(double x)

Returns the closest double approximation of the arc sine of the argument within the range [-pi/2..pi/2].

static double atan(double x)

Returns the closest double approximation of the arc tangent of the argument within the range [-pi/2..pi/2].

static double atan2(double y, double x)

Returns the closest double approximation of the arc tangent of y/x within the range [-pi..pi].

static double cbrt(double x)

Returns the closest double approximation of the cube root of the argument.

static double ceil(double d)

Returns the double conversion of the most negative (closest to negative infinity) integer value greater than or equal to the argument.

static double copySign(double magnitude, double sign)

Returns a double with the given magnitude and the sign of sign.

static float copySign(float magnitude, float sign)

Returns a float with the given magnitude and the sign of sign.

static double cos(double d)

Returns the closest double approximation of the cosine of the argument.

static double cosh(double x)

Returns the closest double approximation of the hyperbolic cosine of the argument.

static double exp(double x)

Returns the closest double approximation of the raising "e" to the power of the argument.

static double expm1(double x)

Returns the closest double approximation of e d- 1.

static double floor(double d)

Returns the double conversion of the most positive (closest to positive infinity) integer less than or equal to the argument.

static int getExponent(float f)

Returns the exponent of float f.

static int getExponent(double d)

Returns the exponent of double d.

static double hypot(double x, double y)

Returns sqrt(x2+ y2).

static double log(double x)

Returns the closest double approximation of the natural logarithm of the argument.

static double log10(double x)

Returns the closest double approximation of the base 10 logarithm of the argument.

static double log1p(double x)

Returns the closest double approximation of the natural logarithm of the sum of the argument and 1.

static long max(long l1, long l2)

Returns the most positive (closest to positive infinity) of the two arguments.

static int max(int i1, int i2)

Returns the most positive (closest to positive infinity) of the two arguments.

static double max(double d1, double d2)

Returns the most positive (closest to positive infinity) of the two arguments.

static float max(float f1, float f2)

Returns the most positive (closest to positive infinity) of the two arguments.

static int min(int i1, int i2)

Returns the most negative (closest to negative infinity) of the two arguments.

static long min(long l1, long l2)

Returns the most negative (closest to negative infinity) of the two arguments.

static double min(double d1, double d2)

Returns the most negative (closest to negative infinity) of the two arguments.

static float min(float f1, float f2)

Returns the most negative (closest to negative infinity) of the two arguments.

static float nextAfter(float start, double direction)

Returns the next float after start in the given direction .

static double nextAfter(double start, double direction)

Returns the next double after start in the given direction.

static double nextUp(double d)

Returns the next double larger than d.

static float nextUp(float f)

Returns the next float larger than f.

static double pow(double x, double y)

Returns the closest double approximation of the result of raising x to the power of y.

static double random()

Returns a pseudo-random number between 0.0 (inclusive) and 1.0 (exclusive).

static double rint(double d)

Returns the double conversion of the result of rounding the argument to an integer.

static long round(double d)

Returns the result of rounding the argument to an integer.

static int round(float f)

Returns the result of rounding the argument to an integer.

static double scalb(double d, int scaleFactor)

Returns d * 2^scaleFactor.

static float scalb(float d, int scaleFactor)

Returns d * 2^scaleFactor.

static double signum(double d)

Returns the signum function of the argument.

static float signum(float f)

Returns the signum function of the argument.

static double sin(double d)

Returns the closest double approximation of the sine of the argument.

static double sinh(double x)

Returns the closest double approximation of the hyperbolic sine of the argument.

static double sqrt(double d)

Returns the closest double approximation of the square root of the argument.

static double tan(double d)

Returns the closest double approximation of the tangent of the argument.

static double tanh(double x)

Returns the closest double approximation of the hyperbolic tangent of the argument.

static double toDegrees(double angrad)

Returns the measure in degrees of the supplied radian angle.

static double toRadians(double angdeg)

Returns the measure in radians of the supplied degree angle.

static float ulp(float f)

Returns the argument's ulp (unit in the last place).

static double ulp(double d)

Returns the argument's ulp (unit in the last place).

Inherited methods

From class java.lang.Object

Constants

E

Added in API level 1
double E

The double value closest to e, the base of the natural logarithm.

Constant Value: 2.718281828459045

PI

Added in API level 1
double PI

The double value closest to pi, the ratio of a circle's circumference to its diameter.

Constant Value: 3.141592653589793

Public methods

IEEEremainder

Added in API level 1
double IEEEremainder (double x, 
                double y)

Returns the remainder of dividing x by y using the IEEE 754 rules. The result is x-round(x/p)*p where round(x/p) is the nearest integer (rounded to even), but without numerical cancellation problems.

Special cases:

  • IEEEremainder((anything), 0) = NaN
  • IEEEremainder(+infinity, (anything)) = NaN
  • IEEEremainder(-infinity, (anything)) = NaN
  • IEEEremainder(NaN, (anything)) = NaN
  • IEEEremainder((anything), NaN) = NaN
  • IEEEremainder(x, +infinity) = x where x is anything but +/-infinity
  • IEEEremainder(x, -infinity) = x where x is anything but +/-infinity

Parameters
x double: the numerator of the operation.
y double: the denominator of the operation.
Returns
double the IEEE754 floating point reminder of of x/y.

abs

Added in API level 1
double abs (double d)

Returns the absolute value of the argument.

Special cases:

  • abs(-0.0) = +0.0
  • abs(+infinity) = +infinity
  • abs(-infinity) = +infinity
  • abs(NaN) = NaN

Parameters
d double
Returns
double

abs

Added in API level 1
long abs (long l)

Returns the absolute value of the argument.

If the argument is Long.MIN_VALUE, Long.MIN_VALUE is returned.

Parameters
l long
Returns
long

abs

Added in API level 1
float abs (float f)

Returns the absolute value of the argument.

Special cases:

  • abs(-0.0) = +0.0
  • abs(+infinity) = +infinity
  • abs(-infinity) = +infinity
  • abs(NaN) = NaN

Parameters
f float
Returns
float

abs

Added in API level 1
int abs (int i)

Returns the absolute value of the argument.

If the argument is Integer.MIN_VALUE, Integer.MIN_VALUE is returned.

Parameters
i int
Returns
int

acos

Added in API level 1
double acos (double x)

Returns the closest double approximation of the arc cosine of the argument within the range [0..pi].

Special cases:

  • acos((anything > 1) = NaN
  • acos((anything < -1) = NaN
  • acos(NaN) = NaN

Parameters
x double: the value to compute arc cosine of.
Returns
double the arc cosine of the argument.

asin

Added in API level 1
double asin (double x)

Returns the closest double approximation of the arc sine of the argument within the range [-pi/2..pi/2].

Special cases:

  • asin((anything > 1)) = NaN
  • asin((anything < -1)) = NaN
  • asin(NaN) = NaN

Parameters
x double: the value whose arc sine has to be computed.
Returns
double the arc sine of the argument.

atan

Added in API level 1
double atan (double x)

Returns the closest double approximation of the arc tangent of the argument within the range [-pi/2..pi/2].

Special cases:

  • atan(+0.0) = +0.0
  • atan(-0.0) = -0.0
  • atan(+infinity) = +pi/2
  • atan(-infinity) = -pi/2
  • atan(NaN) = NaN

Parameters
x double: the value whose arc tangent has to be computed.
Returns
double the arc tangent of the argument.

atan2

Added in API level 1
double atan2 (double y, 
                double x)

Returns the closest double approximation of the arc tangent of y/x within the range [-pi..pi]. This is the angle of the polar representation of the rectangular coordinates (x,y).

Special cases:

  • atan2((anything), NaN ) = NaN;
  • atan2(NaN , (anything) ) = NaN;
  • atan2(+0.0, +(anything but NaN)) = +0.0
  • atan2(-0.0, +(anything but NaN)) = -0.0
  • atan2(+0.0, -(anything but NaN)) = +pi
  • atan2(-0.0, -(anything but NaN)) = -pi
  • atan2(+(anything but 0 and NaN), 0) = +pi/2
  • atan2(-(anything but 0 and NaN), 0) = -pi/2
  • atan2(+(anything but infinity and NaN), +infinity) = +0.0
  • atan2(-(anything but infinity and NaN), +infinity) = -0.0
  • atan2(+(anything but infinity and NaN), -infinity) = +pi
  • atan2(-(anything but infinity and NaN), -infinity) = -pi
  • atan2(+infinity, +infinity ) = +pi/4
  • atan2(-infinity, +infinity ) = -pi/4
  • atan2(+infinity, -infinity ) = +3pi/4
  • atan2(-infinity, -infinity ) = -3pi/4
  • atan2(+infinity, (anything but,0, NaN, and infinity)) = +pi/2
  • atan2(-infinity, (anything but,0, NaN, and infinity)) = -pi/2

Parameters
y double: the numerator of the value whose atan has to be computed.
x double: the denominator of the value whose atan has to be computed.
Returns
double the arc tangent of y/x.

cbrt

Added in API level 1
double cbrt (double x)

Returns the closest double approximation of the cube root of the argument.

Special cases:

  • cbrt(+0.0) = +0.0
  • cbrt(-0.0) = -0.0
  • cbrt(+infinity) = +infinity
  • cbrt(-infinity) = -infinity
  • cbrt(NaN) = NaN

Parameters
x double: the value whose cube root has to be computed.
Returns
double the cube root of the argument.

ceil

Added in API level 1
double ceil (double d)

Returns the double conversion of the most negative (closest to negative infinity) integer value greater than or equal to the argument.

Special cases:

  • ceil(+0.0) = +0.0
  • ceil(-0.0) = -0.0
  • ceil((anything in range (-1,0)) = -0.0
  • ceil(+infinity) = +infinity
  • ceil(-infinity) = -infinity
  • ceil(NaN) = NaN

Parameters
d double
Returns
double

copySign

Added in API level 9
double copySign (double magnitude, 
                double sign)

Returns a double with the given magnitude and the sign of sign. If sign is NaN, the sign of the result is positive.

Parameters
magnitude double
sign double
Returns
double

copySign

Added in API level 9
float copySign (float magnitude, 
                float sign)

Returns a float with the given magnitude and the sign of sign. If sign is NaN, the sign of the result is positive.

Parameters
magnitude float
sign float
Returns
float

cos

Added in API level 1
double cos (double d)

Returns the closest double approximation of the cosine of the argument.

Special cases:

  • cos(+infinity) = NaN
  • cos(-infinity) = NaN
  • cos(NaN) = NaN

Parameters
d double: the angle whose cosine has to be computed, in radians.
Returns
double the cosine of the argument.

cosh

Added in API level 1
double cosh (double x)

Returns the closest double approximation of the hyperbolic cosine of the argument.

Special cases:

  • cosh(+infinity) = +infinity
  • cosh(-infinity) = +infinity
  • cosh(NaN) = NaN

Parameters
x double: the value whose hyperbolic cosine has to be computed.
Returns
double the hyperbolic cosine of the argument.

exp

Added in API level 1
double exp (double x)

Returns the closest double approximation of the raising "e" to the power of the argument.

Special cases:

  • exp(+infinity) = +infinity
  • exp(-infinity) = +0.0
  • exp(NaN) = NaN

Parameters
x double: the value whose exponential has to be computed.
Returns
double the exponential of the argument.

expm1

Added in API level 1
double expm1 (double x)

Returns the closest double approximation of e d- 1. If the argument is very close to 0, it is much more accurate to use expm1(d)+1 than exp(d) (due to cancellation of significant digits).

Special cases:

  • expm1(+0.0) = +0.0
  • expm1(-0.0) = -0.0
  • expm1(+infinity) = +infinity
  • expm1(-infinity) = -1.0
  • expm1(NaN) = NaN

Parameters
x double: the value to compute the ed - 1 of.
Returns
double the ed- 1 value of the argument.

floor

Added in API level 1
double floor (double d)

Returns the double conversion of the most positive (closest to positive infinity) integer less than or equal to the argument.

Special cases:

  • floor(+0.0) = +0.0
  • floor(-0.0) = -0.0
  • floor(+infinity) = +infinity
  • floor(-infinity) = -infinity
  • floor(NaN) = NaN

Parameters
d double
Returns
double

getExponent

Added in API level 9
int getExponent (float f)

Returns the exponent of float f.

Parameters
f float
Returns
int

getExponent

Added in API level 9
int getExponent (double d)

Returns the exponent of double d.

Parameters
d double
Returns
int

hypot

Added in API level 1
double hypot (double x, 
                double y)

Returns sqrt(x2+ y2). The final result is without medium underflow or overflow.

Special cases:

  • hypot(+infinity, (anything including NaN)) = +infinity
  • hypot(-infinity, (anything including NaN)) = +infinity
  • hypot((anything including NaN), +infinity) = +infinity
  • hypot((anything including NaN), -infinity) = +infinity
  • hypot(NaN, NaN) = NaN

Parameters
x double: a double number.
y double: a double number.
Returns
double the sqrt(x2+ y2) value of the arguments.

log

Added in API level 1
double log (double x)

Returns the closest double approximation of the natural logarithm of the argument.

Special cases:

  • log(+0.0) = -infinity
  • log(-0.0) = -infinity
  • log((anything < 0) = NaN
  • log(+infinity) = +infinity
  • log(-infinity) = NaN
  • log(NaN) = NaN

Parameters
x double: the value whose log has to be computed.
Returns
double the natural logarithm of the argument.

log10

Added in API level 1
double log10 (double x)

Returns the closest double approximation of the base 10 logarithm of the argument.

Special cases:

  • log10(+0.0) = -infinity
  • log10(-0.0) = -infinity
  • log10((anything < 0) = NaN
  • log10(+infinity) = +infinity
  • log10(-infinity) = NaN
  • log10(NaN) = NaN

Parameters
x double: the value whose base 10 log has to be computed.
Returns
double the the base 10 logarithm of x

log1p

Added in API level 1
double log1p (double x)

Returns the closest double approximation of the natural logarithm of the sum of the argument and 1. If the argument is very close to 0, it is much more accurate to use log1p(d) than log(1.0+d) (due to numerical cancellation).

Special cases:

  • log1p(+0.0) = +0.0
  • log1p(-0.0) = -0.0
  • log1p((anything < 1)) = NaN
  • log1p(-1.0) = -infinity
  • log1p(+infinity) = +infinity
  • log1p(-infinity) = NaN
  • log1p(NaN) = NaN

Parameters
x double: the value to compute the ln(1+d) of.
Returns
double the natural logarithm of the sum of the argument and 1.

max

Added in API level 1
long max (long l1, 
                long l2)

Returns the most positive (closest to positive infinity) of the two arguments.

Parameters
l1 long
l2 long
Returns
long

max

Added in API level 1
int max (int i1, 
                int i2)

Returns the most positive (closest to positive infinity) of the two arguments.

Parameters
i1 int
i2 int
Returns
int

max

Added in API level 1
double max (double d1, 
                double d2)

Returns the most positive (closest to positive infinity) of the two arguments.

Special cases:

  • max(NaN, (anything)) = NaN
  • max((anything), NaN) = NaN
  • max(+0.0, -0.0) = +0.0
  • max(-0.0, +0.0) = +0.0

Parameters
d1 double
d2 double
Returns
double

max

Added in API level 1
float max (float f1, 
                float f2)

Returns the most positive (closest to positive infinity) of the two arguments.

Special cases:

  • max(NaN, (anything)) = NaN
  • max((anything), NaN) = NaN
  • max(+0.0, -0.0) = +0.0
  • max(-0.0, +0.0) = +0.0

Parameters
f1 float
f2 float
Returns
float

min

Added in API level 1
int min (int i1, 
                int i2)

Returns the most negative (closest to negative infinity) of the two arguments.

Parameters
i1 int
i2 int
Returns
int

min

Added in API level 1
long min (long l1, 
                long l2)

Returns the most negative (closest to negative infinity) of the two arguments.

Parameters
l1 long
l2 long
Returns
long

min

Added in API level 1
double min (double d1, 
                double d2)

Returns the most negative (closest to negative infinity) of the two arguments.

Special cases:

  • min(NaN, (anything)) = NaN
  • min((anything), NaN) = NaN
  • min(+0.0, -0.0) = -0.0
  • min(-0.0, +0.0) = -0.0

Parameters
d1 double
d2 double
Returns
double

min

Added in API level 1
float min (float f1, 
                float f2)

Returns the most negative (closest to negative infinity) of the two arguments.

Special cases:

  • min(NaN, (anything)) = NaN
  • min((anything), NaN) = NaN
  • min(+0.0, -0.0) = -0.0
  • min(-0.0, +0.0) = -0.0

Parameters
f1 float
f2 float
Returns
float

nextAfter

Added in API level 9
float nextAfter (float start, 
                double direction)

Returns the next float after start in the given direction .

Parameters
start float
direction double
Returns
float

nextAfter

Added in API level 9
double nextAfter (double start, 
                double direction)

Returns the next double after start in the given direction.

Parameters
start double
direction double
Returns
double

nextUp

Added in API level 9
double nextUp (double d)

Returns the next double larger than d.

Parameters
d double
Returns
double

nextUp

Added in API level 9
float nextUp (float f)

Returns the next float larger than f.

Parameters
f float
Returns
float

pow

Added in API level 1
double pow (double x, 
                double y)

Returns the closest double approximation of the result of raising x to the power of y.

Special cases:

  • pow((anything), +0.0) = 1.0
  • pow((anything), -0.0) = 1.0
  • pow(x, 1.0) = x
  • pow((anything), NaN) = NaN
  • pow(NaN, (anything except 0)) = NaN
  • pow(+/-(|x| > 1), +infinity) = +infinity
  • pow(+/-(|x| > 1), -infinity) = +0.0
  • pow(+/-(|x| < 1), +infinity) = +0.0
  • pow(+/-(|x| < 1), -infinity) = +infinity
  • pow(+/-1.0 , +infinity) = NaN
  • pow(+/-1.0 , -infinity) = NaN
  • pow(+0.0, (+anything except 0, NaN)) = +0.0
  • pow(-0.0, (+anything except 0, NaN, odd integer)) = +0.0
  • pow(+0.0, (-anything except 0, NaN)) = +infinity
  • pow(-0.0, (-anything except 0, NAN, odd integer)) = +infinity
  • pow(-0.0, (odd integer)) = -pow( +0 , (odd integer) )
  • pow(+infinity, (+anything except 0, NaN)) = +infinity
  • pow(+infinity, (-anything except 0, NaN)) = +0.0
  • pow(-infinity, (anything)) = -pow(0, (-anything))
  • pow((-anything), (integer)) = pow(-1,(integer))*pow(+anything,integer)
  • pow((-anything except 0 and infinity), (non-integer)) = NAN

Parameters
x double: the base of the operation.
y double: the exponent of the operation.
Returns
double x to the power of y.

random

Added in API level 1
double random ()

Returns a pseudo-random number between 0.0 (inclusive) and 1.0 (exclusive).

Returns
double a pseudo-random number.

rint

Added in API level 1
double rint (double d)

Returns the double conversion of the result of rounding the argument to an integer. Tie breaks are rounded towards even.

Special cases:

  • rint(+0.0) = +0.0
  • rint(-0.0) = -0.0
  • rint(+infinity) = +infinity
  • rint(-infinity) = -infinity
  • rint(NaN) = NaN

Parameters
d double: the value to be rounded.
Returns
double the closest integer to the argument (as a double).

round

Added in API level 1
long round (double d)

Returns the result of rounding the argument to an integer. The result is equivalent to (long) Math.floor(d+0.5).

Special cases:

  • round(+0.0) = +0.0
  • round(-0.0) = +0.0
  • round((anything > Long.MAX_VALUE) = Long.MAX_VALUE
  • round((anything < Long.MIN_VALUE) = Long.MIN_VALUE
  • round(+infinity) = Long.MAX_VALUE
  • round(-infinity) = Long.MIN_VALUE
  • round(NaN) = +0.0

Parameters
d double: the value to be rounded.
Returns
long the closest integer to the argument.

round

Added in API level 1
int round (float f)

Returns the result of rounding the argument to an integer. The result is equivalent to (int) Math.floor(f+0.5).

Special cases:

  • round(+0.0) = +0.0
  • round(-0.0) = +0.0
  • round((anything > Integer.MAX_VALUE) = Integer.MAX_VALUE
  • round((anything < Integer.MIN_VALUE) = Integer.MIN_VALUE
  • round(+infinity) = Integer.MAX_VALUE
  • round(-infinity) = Integer.MIN_VALUE
  • round(NaN) = +0.0

Parameters
f float: the value to be rounded.
Returns
int the closest integer to the argument.

scalb

Added in API level 9
double scalb (double d, 
                int scaleFactor)

Returns d * 2^scaleFactor. The result may be rounded.

Parameters
d double
scaleFactor int
Returns
double

scalb

Added in API level 9
float scalb (float d, 
                int scaleFactor)

Returns d * 2^scaleFactor. The result may be rounded.

Parameters
d float
scaleFactor int
Returns
float

signum

Added in API level 1
double signum (double d)

Returns the signum function of the argument. If the argument is less than zero, it returns -1.0. If the argument is greater than zero, 1.0 is returned. If the argument is either positive or negative zero, the argument is returned as result.

Special cases:

  • signum(+0.0) = +0.0
  • signum(-0.0) = -0.0
  • signum(+infinity) = +1.0
  • signum(-infinity) = -1.0
  • signum(NaN) = NaN

Parameters
d double: the value whose signum has to be computed.
Returns
double the value of the signum function.

signum

Added in API level 1
float signum (float f)

Returns the signum function of the argument. If the argument is less than zero, it returns -1.0. If the argument is greater than zero, 1.0 is returned. If the argument is either positive or negative zero, the argument is returned as result.

Special cases:

  • signum(+0.0) = +0.0
  • signum(-0.0) = -0.0
  • signum(+infinity) = +1.0
  • signum(-infinity) = -1.0
  • signum(NaN) = NaN

Parameters
f float: the value whose signum has to be computed.
Returns
float the value of the signum function.

sin

Added in API level 1
double sin (double d)

Returns the closest double approximation of the sine of the argument.

Special cases:

  • sin(+0.0) = +0.0
  • sin(-0.0) = -0.0
  • sin(+infinity) = NaN
  • sin(-infinity) = NaN
  • sin(NaN) = NaN

Parameters
d double: the angle whose sin has to be computed, in radians.
Returns
double the sine of the argument.

sinh

Added in API level 1
double sinh (double x)

Returns the closest double approximation of the hyperbolic sine of the argument.

Special cases:

  • sinh(+0.0) = +0.0
  • sinh(-0.0) = -0.0
  • sinh(+infinity) = +infinity
  • sinh(-infinity) = -infinity
  • sinh(NaN) = NaN

Parameters
x double: the value whose hyperbolic sine has to be computed.
Returns
double the hyperbolic sine of the argument.

sqrt

Added in API level 1
double sqrt (double d)

Returns the closest double approximation of the square root of the argument.

Special cases:

  • sqrt(+0.0) = +0.0
  • sqrt(-0.0) = -0.0
  • sqrt( (anything < 0) ) = NaN
  • sqrt(+infinity) = +infinity
  • sqrt(NaN) = NaN

Parameters
d double
Returns
double

tan

Added in API level 1
double tan (double d)

Returns the closest double approximation of the tangent of the argument.

Special cases:

  • tan(+0.0) = +0.0
  • tan(-0.0) = -0.0
  • tan(+infinity) = NaN
  • tan(-infinity) = NaN
  • tan(NaN) = NaN

Parameters
d double: the angle whose tangent has to be computed, in radians.
Returns
double the tangent of the argument.

tanh

Added in API level 1
double tanh (double x)

Returns the closest double approximation of the hyperbolic tangent of the argument. The absolute value is always less than 1.

Special cases:

  • tanh(+0.0) = +0.0
  • tanh(-0.0) = -0.0
  • tanh(+infinity) = +1.0
  • tanh(-infinity) = -1.0
  • tanh(NaN) = NaN

Parameters
x double: the value whose hyperbolic tangent has to be computed.
Returns
double the hyperbolic tangent of the argument

toDegrees

Added in API level 1
double toDegrees (double angrad)

Returns the measure in degrees of the supplied radian angle. The result is angrad * 180 / pi.

Special cases:

  • toDegrees(+0.0) = +0.0
  • toDegrees(-0.0) = -0.0
  • toDegrees(+infinity) = +infinity
  • toDegrees(-infinity) = -infinity
  • toDegrees(NaN) = NaN

Parameters
angrad double: an angle in radians.
Returns
double the degree measure of the angle.

toRadians

Added in API level 1
double toRadians (double angdeg)

Returns the measure in radians of the supplied degree angle. The result is angdeg / 180 * pi.

Special cases:

  • toRadians(+0.0) = +0.0
  • toRadians(-0.0) = -0.0
  • toRadians(+infinity) = +infinity
  • toRadians(-infinity) = -infinity
  • toRadians(NaN) = NaN

Parameters
angdeg double: an angle in degrees.
Returns
double the radian measure of the angle.

ulp

Added in API level 1
float ulp (float f)

Returns the argument's ulp (unit in the last place). The size of a ulp of a float value is the positive distance between this value and the float value next larger in magnitude. For non-NaN x, ulp(-x) == ulp(x).

Special cases:

  • ulp(+0.0) = Float.MIN_VALUE
  • ulp(-0.0) = Float.MIN_VALUE
  • ulp(+infinity) = infinity
  • ulp(-infinity) = infinity
  • ulp(NaN) = NaN

Parameters
f float: the floating-point value to compute ulp of.
Returns
float the size of a ulp of the argument.

ulp

Added in API level 1
double ulp (double d)

Returns the argument's ulp (unit in the last place). The size of a ulp of a double value is the positive distance between this value and the double value next larger in magnitude. For non-NaN x, ulp(-x) == ulp(x).

Special cases:

  • ulp(+0.0) = Double.MIN_VALUE
  • ulp(-0.0) = Double.MIN_VALUE
  • ulp(+infinity) = infinity
  • ulp(-infinity) = infinity
  • ulp(NaN) = NaN

Parameters
d double: the floating-point value to compute ulp of.
Returns
double the size of a ulp of the argument.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.