Solved
TFloatfields ??
Posted on 2000-03-22
Hi,
This is just a general question about Delphi TFloatfields. I am just wondering why if I set a field to
Field Name Type Size Decimals
MYFIELD F 6 2
that if I have a number stored in this field as 21.30 for example and then read that into a Real variable i get the following.
If I do Frac(21.30) I find the result to be 0.299999999. Why is that if I have specified the 2 decimal places in the database table. Where does this problem originate from ?? As you could understand this becomes a problem if I use a rounding function as it rounds down rather that up. For example if I round 21.30 in Delphi to the nearest 0.2 I get 21.2 rather that 21.4.
I know setting the field type as TBCDField will fix the problem but I want some discussion on how this comes to be. Any of the Gurus got an answer to this one ?
Regards,
Westy :)