On Fri, 4 Sep 1998, Steve Curry wrote:
> I have installed JDK 1.1.6 on my RedHat 5.0 Linux box and when performing
> mathmatical calculations in java I get incorrect results. Take for example
> (float)14.39 I can do a basic System.out.println and it will print out on
> the command line: 14.3899999999999. What is wrong with my JDK 1.1.6? I am
> new to Java so hopefully I'm just missing something small here.
There is nothing wrong with the JDK; this is standard behaviour for
floating point numbers, because of the way they are stored by the
computer. Using the double type you will have more precision, but you will
still have problems like this, so if you absolutely must have 100% sharp
precision you must use other ways, like fixed point numbers simulated with
integers, or something.