On Tue, Aug 2, 2011 at 12:18 PM, Mathias Legerer
<mathias.lege...@gmail.com>wrote:

> Hi,
> I noticed a strange behaviour, when i have a table with a text-field
> and i put a big float-number into it.
> When stored, it is increased by one.
>

Floating-point numbers are approximations.  Always.  No exceptions.  SQLite
promises to preserve 14 significant digits.  You're getting 15.5 significant
digits.  Count your blessings.

(1) Unless you are doing number theory or cryptography, you don't need that
many significant digits.  No real quantity can be measured with that much
accuracy.

(2) If your boss or your customer insists that you preserve more digits (in
spite of the fact that in any real-world application, anything after about
the 5th or 6th digit is probably just noise), then use integers.

FWIW, Linux preserves all 16 digits.  I suppose the difference is how winXP
sets up the on-chip floating point hardware.


>
> create table TEST (ordnr int primary key, ktoid TEXT);
> insert into TEST (ordnr, ktoid) values(0, 991000004499464.0);
> SELECT ordnr, ktoid FROM TEST;
> 0|991000004499465.0
>
> I believe, this is just because of some conversion-library.
> Documenation says: "If numerical data is inserted into a column with
> TEXT affinity it is converted into text form before being stored"
>
>  I thought that this would work without any problems, but it seems
> there is some limit for floats/real as text if you look at this bigger
> number:
> insert into TEST (ordnr, ktoid) values(3, 99100000449946222.0);
> -> 3|9.91000004499462e+16
>
> Is there some documentation about this limit?
> Is it system-dependend?
> I am working on WinXP 32Bit.
>
> Thank you for any information.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



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

Reply via email to