- Java.math package classes
- Java.math - Home
- Java.math - BigDecimal
- Java.math - BigInteger
- Java.math - MathContext
- Java.math package extras
- Java.math - Enumerations
- Java.math - Discussion
Java.math.BigDecimal.min() Method
Description
The java.math.BigDecimal.min(BigDecimal val) returns the minimum of this BigDecimal and val.
Declaration
Following is the declaration for java.math.BigDecimal.min() method.
public BigDecimal min(BigDecimal val)
Parameters
val − Value with which the maximum is to be computed.
Return Value
This method returns the BigDecimal whose value is the lesser of this BigDecimal and val. If they are equal, as defined by the compareTo method, this is returned.
Exception
NA
Example
The following example shows the usage of math.BigDecimal.min() method.
package com.tutorialspoint; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 3 BigDecimal objects BigDecimal bg1, bg2, bg3; bg1 = new BigDecimal("235"); bg2 = new BigDecimal("236"); // assign the min value of bg1, bg2 to bg3 bg3 = bg1.min(bg2); String str = "Minimum Value among " + bg1 + " and "+ bg2+" is "+ bg3; // print the minimum value System.out.println( str ); } }
Let us compile and run the above program, this will produce the following result −
Minimum Value among 235 and 236 is 235
java_math_bigdecimal.htm
Advertisements
To Continue Learning Please Login
Login with Google