[fpc-devel] MySQL 5.1 and Double (trouble)
    Hans-Peter Diettrich 
    DrDiettrich1 at aol.com
       
    Mon Jul 11 18:55:37 CEST 2011
    
    
  
Andrew Brunner schrieb:
>> It doesn't make sense to display more digits than stored in the binary
>> variable. There is no loss, only rounding errors in the conversion from
>> binary to decimal text.
> 
> I need to compare values with complete precision.  I don't think this
> problem was present a while ago.
Floating point numbers never should be compared for equality. Better:
   if abs(a-b) < delta then ...
with delta corresponding to the available accuracy (e.g. 1E-15).
As a rule of thumb: 10^3 ~ 2^10, i.e. 3 decimal digits require 10 bits 
in the significand, so that 52 bits allow for 52*3/10 ~ 15 digits.
> When the memory is copied is there a missing 12bits?  Is there going
> to be a fix for this?
The binary value consists of an exponent and an significand (mantissa), 
most probably you forgot to count the exponent and sign bits.
I'd suggest that you read a bit about using floating point numbers. They 
never are accurate, and every decimal representation adds more 
inaccuracy :-(
DoDi
    
    
More information about the fpc-devel
mailing list