Java - Number

1 - About

Number, Numeric, Quantity in Java.

The abstract class Number is the superclass of platform classes representing numeric values that are convertible to the primitive types byte, double, float, int, long, and short.

3 - Double to Integer

Double d = 5.25;
Integer i = d.intValue(); // i becomes 5
// or
double d = 5.25;
int i = (int) d;

4 - BigDecimal

  • Bigger than and bigger or equal
value.compareTo(BigDecimal.valueOf(10)) > 0
value.compareTo(BigDecimal.valueOf(10)) >= 0
  • Less Than and less than or equal
value.compareTo(BigDecimal.valueOf(10)) < 0
value.compareTo(BigDecimal.valueOf(10)) <= 0

5 - Documentation / Reference

lang/java/number.txt ยท Last modified: 2018/05/02 08:09 by gerardnico