it is strange that I named a float variable and value it with 3.14, but it show me a 3.1399968427..........in the screen, what's wrong ? :confused:

Note: my soft is BCB.

Printable View

- 05-07-2002blackI got a 3.1399968427..........
it is strange that I named a float variable and value it with 3.14, but it show me a 3.1399968427..........in the screen, what's wrong ? :confused:

Note: my soft is BCB. - 05-07-2002Imperito
There are a number of situations where floats arent accurate, but I don't recall ever seeing one EXTEND output, usually it gets truncated.

The cause is that a float uses [implementation-defined] ones and zeros to represent the mantissa (decimal part) and occasionally certain decimal values cannot be represented using that number of bits. Binary numbers are good for integers, but when you get into part of numbers, errors happen. Using doubles or long doubles can stave this off, but for any number of mantissa bits, there are still decimal numbers that cannot be represented.