decrementExact(): This method is available in the Math class of Java.
Syntax:
long java.lang.Math.decrementExact(long a)
This method takes one parameter of type long. This method returns the argument decremented by one. It throwing an exception if the result overflows a long.
Note: The overflow only occurs for the minimum value.
Parameters:One parameter is required for this method.
a: the value to decrement
Returns:the result.
Note: It Throws ArithmeticException - if the result overflows a long.
For Example:
decrementExact(1999199191) = > It returns 1999199190
Approach
Java
public class DecrementExactLong {public static void main(String[] args) {long a = 1999199191;System.out.println(Math.decrementExact(a));}}
Output:
1999199190
No comments:
Post a Comment