Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

nextDown()

Example

Determine the subsequent floating-point number that is lower than various given numbers.

System.out.println(Math.nextDown(1.0f));
System.out.println(Math.nextDown(1.0));
System.out.println(Math.nextDown(0.5f));
System.out.println(Math.nextDown(0.5));
System.out.println(Math.nextDown(Math.PI));
System.out.println(Math.nextDown(3.1415927f));

Definition and Usage

The nextDown() method in Java retrieves the floating-point number adjacent to a given number in the negative direction, specifically the highest possible floating-point number that is less than the starting number.

For double type arguments, the returned value will be closer to the starting number than for float type arguments.

Syntax

One of the following:

public static double nextDown(double start) 

 

public static float nextDown(float start) 

Parameter Values

Parameter

Description

start

Please specify the starting number.

Technical Details

Returns:

A double or float value representing the floating-point number that is adjacent to a starting number in the negative direction.

Java Version

1.8+