-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (16 loc) · 679 Bytes
/
Main.java
File metadata and controls
27 lines (16 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
public static double bigDecimalToDouble(BigDecimal bigDecimal){
return bigDecimal.setScale(2, RoundingMode.HALF_UP).negate().doubleValue();
}
public double reverseBigDecimal (BigDecimal bigDecimal){
return bigDecimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
}
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("35.7656");
double result = bigDecimalToDouble (bigDecimal);
//System.out.printf("Result bigDecimalToDouble method: %f", result);
System.out.println( result);
}
}//end