You cannot store 212345678901234567890123456.988290112 using IEEE a 8 byte 
double precision. You cannot do this even with a 16 byte (long double - which 
for x86 architectures is actually 80-bit extended precision - only 64 bit for 
mantissa; is not the quadruple precision).

If you care about precision, then don't use regular floating point operations, 
use a library implementing arbitrary precision operations (ex. 
http://gmplib.org/). You can then store the numbers as blobs. If you need to 
use these columns in expressions for queries ... well, is not straightforward, 
but it can be done with sqlite. Of course, it won't be as efficient. Or you can 
store them as strings and do some tricks.

On the other hand, I see that these columns are named powervalue_1 and 2, 
suggesting that they are the result of some form of pow - you can store then 
the arguments for pow, if this fit your needs..

I'm curious, how did you get the number 212345678901234567890123456.988290112 ?

-ic

--- On Wed, 10/28/09, liubin liu <7101...@sina.com> wrote:

> From: liubin liu <7101...@sina.com>
> Subject: [sqlite]  How to input a double num?
> To: sqlite-users@sqlite.org
> Date: Wednesday, October 28, 2009, 9:48 PM
> 
> Now I use the sqlite3_mprintf() and the "%f" to get the
> double num. My code
> is below.
> 
> Now there is a num like
> "212345678901234567890123456.988290112". With the
> way of "sqlite3_mprintf()" and "%f", the num is cut to
> "212345678901234600000000000.000000".
> 
> 
> How to input the num
> "212345678901234567890123456.988290112"?
> 
> 
> code_________________________________________________
> 
> ...
>     char *query_format = "INSERT OR REPLACE INTO
> pow_value_st (id, valid,
> powervalue_1, powervalue_2) VALUES (%d, %d, %f, %f)";
>     char *query_string = NULL;
>     query_string = sqlite3_mprintf (query_format,
> index, tc->valid,
> tc->powervalue[0], tc->powervalue[1]);
>     printf ("%s\n", query_string); 
> ...
> 
> -- 
> View this message in context: 
> http://www.nabble.com/How-to-input-a-double-num--tp26105457p26105457.html
> Sent from the SQLite mailing list archive at Nabble.com.
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 


      

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to