Computer scienceProgramming languagesJavaAdditional instrumentsEssential standard classesStandard classes for computations

BigDecimal

Conversion

Report a typo

Print the result of the following program:

BigDecimal number = new BigDecimal("2.001");
number = number.add(BigDecimal.ONE);
number = number.negate();
number.setScale(1, RoundingMode.HALF_DOWN);
System.out.println(number);
Enter a number
___

Create a free account to access the full topic