[fpc-devel] MySQL 5.1 and Double (trouble)

LacaK lacak at zoznam.sk
Tue Jul 12 13:00:29 CEST 2011


May be, that this can be fixed in sqldb.pp in function 
TSQLConnection.GetAsSQLText(Param: TParam) : string;
...
-    ftFloat    : Result := FloatToStr(Param.AsFloat, FSQLFormatSettings);
+    ftFloat    : Result := FloatToStrF(extended(Param.AsFloat), 
ffGeneral, 16, 0, FSQLFormatSettings);
...
for me it seems, that works ... See atached program.
What do you think ?
-Laco.

> On Mon, Jul 11, 2011 at 11:55 AM, Hans-Peter Diettrich
> <DrDiettrich1 at aol.com> wrote:
>
>   
>> The binary value consists of an exponent and an significand (mantissa), most
>> probably you forgot to count the exponent and sign bits.
>>     
>
> The problem I'm trying to describe is with double precision floating
> point values.  When the query is open and one of the parameters is
> double MySQL does not receive all of the memory.  It's missing two
> bits.  That is a problem with either the mysql5.1 driver or with the
> mysql51 component w/r/t the double data type.
>
>   
>> I'd suggest that you read a bit about using floating point numbers. They
>> never are accurate, and every decimal representation adds more inaccuracy
>>     
>
> I could understand if you wanted to bring this fact into argument over
> arithmetic and cumulative error.  But the fact is - if I send a double
> precision data value to a double precision field in the SQL database -
> that value had better be the same - "bit for bit".  Now if someone is
> being bit shifty on the conversion - that needs to be a addressed.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110712/c33aefaa/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testDouble.lpr
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110712/c33aefaa/attachment.ksh>


More information about the fpc-devel mailing list