Why would an application need to use the SQLite printf function to convert 
doubles to formatted text?  The application ought to store and retrieve the raw 
doubles completely unadulterated (with no diddling, using the value_double and 
bind_double interfaces), and "format the value for display" when it is 
displayed.

---
Theory is when you know everything but nothing works.  Practice is when 
everything works but no one knows why.  Sometimes theory and practice are 
combined:  nothing works and no one knows why.


>-----Original Message-----
>From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>boun...@sqlite.org] On Behalf Of Kees Nuyt
>Sent: Saturday, 7 February, 2015 18:14
>To: sqlite-users@sqlite.org
>Subject: Re: [sqlite] Bug in SQLite FLOAT values
>
>On Sat, 7 Feb 2015 11:27:59 +0530, Abdul Aziz <abduldblog...@gmail.com>
>wrote:
>
>> Hi there!
>> I hope you are well!
>>
>> Recently I was working on project based on Android Sensors and
>encountered
>> a bug in sqlite db, situation was this:
>> I was setting there three values x,y,z as FLOAT, android inbuilt
>sensors
>> were receiving values as float upto 8 decimal places, but I wanted to
>store
>> value only upto 6 decimal place, so in android this is the way that
>first
>> you will have to convert that value into String , as* String sLongitude
>=
>> String.format("%.6f", x);*
>
>As others have said, you shouldn't confuse the storage
>format (how a value is stored in the database) with
>the presentation (how data is displayed on output).
>
>Luckily, recently sqlite got a printf() function.
>
>Demo:
>
>$ sqlite3 test.db
>SQLite version 3.8.8 2015-01-30 20:59:27
>Enter ".help" for usage hints.
>sqlite> create table t3 (id INTEGER PRIMARY KEY, lat REAL, lon REAL);
>sqlite> insert into t3 (id,lat,lon) VALUES
>(1,1.234567890123,5.6789012345678);
>sqlite> select printf('id:%3d, latitude: %9.6f, longitude:
>%9.6f',id,lat,lon) from t3;
>id:  1, latitude:  1.234568, longitude:  5.678901
>sqlite>
>
>Hope this helps.
>
>--
>Regards,
>
>Kees Nuyt
>
>_______________________________________________
>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