On 2015/02/07 15:47, Abdul Aziz wrote:
Thanks for reply....but I am now using VARCHARS, then how this is working?
not generating any errors?

Please elaborate, my query to create DB is:
mSQLiteDatabase.execSQL("CREATE TABLE " + tableName
+ " ( "
+ EVENT_TIME + " INTEGER, " + SYSTEM_TIME + " INTEGER PRIMARY KEY, "
+ ACCURACY + " INTEGER," + X + " VARCHAR, " + Y + " VARCHAR, " + Z
+ " VARCHAR );");

It translates Varchar to Text, that's why no errors are generated, it understands what you mean by Varchar, which is really just some text, so it translates it to the internal type TEXT.

As for your question about decimal points and floats, no float in any language stores values up to a certain length... lengths are the domain of Strings and text, not Floating point numbers. any floating point number is an approximate number with a representation as close as is possible to the actual number. That representation includes many significant digits in the significand and an exponent. You may need to read up on floats some more to see how it works - my point is just that it doesn't store numbers up to a certain length, for that you need a formatter.

Many DB engines offer formatted types, such as Decimal (in PG, Oracle, MSSQL, etc) where you can say you need the number with so many decimals after the point. In SQLite you can format the output (much like your C solution) by doing SELECT printf('%.6f',somevalue); etc.

Read the pages offered by the other posters and maye check out the Wikipedia pages on floating point storage and representation to understand WHY all the above happens, but to solve your immediate problem, use the output formatting or store as strings - there is no way to tell a true floating number to keep itself short.

Other interesting things you can see about this floating point problem (it's a mathematical problem too), look on youtube for "Why is 0.99999... equal to 1?" or "How do we know two numbers are distinct?" - The Numberphile videos in general do a good job of explaining it.

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

Reply via email to