Decimal literals, such as the one you typed by default, enter double , not float . java.lang.Number also uses default doubling. If you replaced this with java.lang.Number numberVal = 676543.21f; , I would expect the same level of accuracy of losses from both. Alternatively replace float floatVal = numberVal.floatValue(); on double doubleVal = numberVal.doubleValue(); In order not to lose accuracy.
As an example, try EDIT:
Number num = 676543.21; System.out.println(num);
to see the difference in type accuracy
Float.MAX_VALUE returns the largest value that a float can hold. any excess overflow. If you look closely, you will see an βEβ in your text view. This is the standard form of the index, that "E" means "multiply by 10 by the power of any number following E" (or in java-speak * pow (10, numberAfterE))
source share