.nextDown()
Anonymous contributor
Published Oct 21, 2022
Contribute to Docs
The Math.nextDown()
method returns the floating-point value adjacent to the parameter provided in the direction of negative infinity.
Syntax
Math.nextDown(x)
- The
x
parameter can be of typedouble
orfloat
. - The return type is of
double
orfloat
. - Though it is the opposite of
.nextAfter()
, the.nextDown()
method is semantically equivalent tonextAfter(d, Double.NEGATIVE_INFINITY);
ornextAfter(f, Float.NEGATIVE_INFINITY);
.
Note: A
.nextDown()
implementation may run faster than its equivalent.nextAfter()
call.
Special cases include the following:
- If
x
isNaN
, the result isNaN
. - If
x
is negative infinity, the result is negative infinity. - If
x
is zero, the result is-Double.MIN_VALUE
or-Float.MIN_VALUE
.
Example
The following is an example of the .nextDown()
method:
// Test.javapublic class Test {public static void main(String args[]) {double d = 23.44;System.out.println(Math.nextDown(d));}}
This results in the following output:
23.439999999999998
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.