S
Stefan Ram
AFAIK 0.1 in hex is 0x1.(9)ap-4, where »(9)« means an
infinite sequence of »9«. However, Java only stores a
finite number of 9s:
printf( "%a%n", 0.1 )
0x1.999999999999ap-4
. So, since something /positive/ is missing, Javas
representation of 0.1 should be /smaller/ than 0.1, but
println( new java.math.BigDecimal( 0.1 ))
0.1000000000000000055511151231257827021181583404541015625
shows me a value that is /greater/ than 0.1?
Removing more 9s makes the value even larger!
println( new java.math.BigDecimal( 0x1.999999999999ap-4 ));
0.1000000000000000055511151231257827021181583404541015625
println( new java.math.BigDecimal( 0x1.9ap-4 ))
0.10009765625
infinite sequence of »9«. However, Java only stores a
finite number of 9s:
printf( "%a%n", 0.1 )
0x1.999999999999ap-4
. So, since something /positive/ is missing, Javas
representation of 0.1 should be /smaller/ than 0.1, but
println( new java.math.BigDecimal( 0.1 ))
0.1000000000000000055511151231257827021181583404541015625
shows me a value that is /greater/ than 0.1?
Removing more 9s makes the value even larger!
println( new java.math.BigDecimal( 0x1.999999999999ap-4 ));
0.1000000000000000055511151231257827021181583404541015625
println( new java.math.BigDecimal( 0x1.9ap-4 ))
0.10009765625