The nextUp()
method is a static method in the math
package that returns the floating-point number adjacent to the first argument towards the direction of the positive infinity.
Scala internally uses Java implementations of the corresponding methods. This method internally invokes nextUp() method in Java.
math.nextUp(x)
x
: The starting floating point or a double number.The method returns the nearest floating-point/double number in the direction of positive infinity adjacent to the given number.
import scala.mathobject Main extends App {val x: Double = 43.12println(s"starting point - ${x}")val newNum = Math.nextUp(x)println(s"Number adjacent to ${x} towards positive infinity - ${newNum}")}
x
in the direction of positive infinity is obtained by invoking the nextUp()
method. The value returned is stored in newNum.
newNum.
Free Resources