delete this thread please!

Printable View

- 03-18-2009, 12:05 AMAdde1986Code counting error
delete this thread please!

- 03-18-2009, 12:45 AMpbrockway2
The value of

*x***is**incrementing by 0.1.

*x*is a double and the Java language insists that the values and the operations on them follow the IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Standard 754-1985.

What's most significant in the code you posted is that double values only have a finite amount of precision (so they can be used by a computer with a finite amount of memory and time at its disposal). Because of that, the result of incrementing*x*by*y*will**not**, in general, be the same whether we interpret*x*and*y*as (finite precision) Java doubles or (infinite precision) mathematical values.

If the result you observe is not what you want, then incrementing 0 by 0.1 is not appropriate. What you want, in that case, is something else. Which you should describe. - 03-18-2009, 01:02 AMemceenugget
you can round off to 1 decimal place if you like