List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:March 18 2006 3:57am
Subject:Re: Precision of stored doubles
View as plain text  
Nis Haller Baggesen wrote:
> Eg. when storing a number like 1142531234.0 it will get truncated to 
> 1142530000.0 in the database. 

Yes, it seems that it's common for the C and C++ standard libraries to 
use only 6 digits of precision by default.

> SQLString::SQLString(double f) :
> is_string(false),
> dont_escape(false),
> processed(false)
> {
>     ostringstream outs;
>     outs << setprecision(15) << f;
>     assign(outs.str());
> }
> and recompiling the library did not in itself seem to do anything, 

This fix is actually needed, but it only affects template queries, not 
SSQLS queries.  The correct fix is slightly different, but you've 
basically nailed it.  You also have to change several places in query.h 
to fix this for SSQLS.

I've made these changes to the v2.1 branch.  I'm probably going to 
release a beta of it (i.e. "feature complete") soon.  I had other plans 
for things to add to v2.1, but the underwhelming amount of testing for 
the current v2.1 alphas tells me I need to get what I have released if I 
want it tested.  So, look for this fix to appear in a released version 
fairly soon.
Precision of stored doublesNis Haller Baggesen17 Mar
  • Re: Precision of stored doublesWarren Young18 Mar