And if set tcl_precision ...
--------------------------------------------------------------------
#!/usr/local/bin/tclsh8.6
# do_test atof1-1.$i.1
package require platform
puts "\nplatform: [platform::generic]"
set tcl_precision 15
puts "sqlite version: [package require sqlite3]"
sqlite db :memory:
set xf [format %.32e 4.40035364203127786031058909193863e+118]
set x [expr {1*$xf}]
puts [format "\nxf = %.32e\nx = %.15e" $xf $x]
puts [format "\nxf = %.60e\nx = %.60e\n" $xf $x]
puts [format "db eval \"SELECT \$xf=\\\$x\" : %s" [db eval "SELECT $xf=\$x"]]
puts [format "expr { \$xf == \$x } : %s\n" [expr { $xf == $x }]]
puts [format "db eval \"SELECT \$xf\" = %s" [db eval "SELECT $xf"]]
puts [format "db eval \"SELECT \\\$xf\" = %s" [db eval "SELECT \$xf"]]
puts [format "db eval \"SELECT \\\$x\" = %s" [db eval "SELECT \$x"]]
db eval "CREATE TABLE t (a text, b real, c int)"
db eval "INSERT INTO t VALUES($xf,\$xf,1)"
db eval "INSERT INTO t VALUES(\$xf,$xf,2)"
db eval "INSERT INTO t VALUES($xf,$xf,3)"
db eval "INSERT INTO t VALUES(\$xf,\$xf,4)"
puts "\ndb eval \"CREATE TABLE t (a text, b real, c int)\"\n"
db eval {SELECT * FROM t} values {
parray values
puts ""
}
db close
--------------------------------------------------------------------
FreeBSD 9.1-RELEASE #0 r243826: Tue Dec 4 06:55:39 UTC 2012
[email protected]:/usr/obj/usr/src/sys/GENERIC i386
tcl-8.6.0
set tcl_precision 15
platform: freebsd-ix86
sqlite version: 3.7.15.1
xf = 4.40035364203127786031058909193863e+118
x = 4.400353642031278e+118
xf = 4.400353642031277860310589091938627241607447857305708019118800e+118
x = 4.400353642031277860310589091938627241607447857305708019118800e+118
db eval "SELECT $xf=\$x" : 0
expr { $xf == $x } : 1
db eval "SELECT $xf" = 4.40035364203128e+118
db eval "SELECT \$xf" = 4.40035364203128e+118
db eval "SELECT \$x" = 4.40035364203128e+118
db eval "CREATE TABLE t (a text, b real, c int)"
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.40035364203128e+118
values(c) = 1
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.40035364203128e+118
values(c) = 2
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.40035364203128e+118
values(c) = 3
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.40035364203128e+118
values(c) = 4
--------------------------------------------------------------------
FreeBSD 9.1-RELEASE #0 r243826: Tue Dec 4 06:55:39 UTC 2012
[email protected]:/usr/obj/usr/src/sys/GENERIC i386
tcl-8.6.0
set tcl_precision 14
platform: freebsd-ix86
sqlite version: 3.7.15.1
xf = 4.40035364203127786031058909193863e+118
x = 4.400353642031278e+118
xf = 4.400353642031277860310589091938627241607447857305708019118800e+118
x = 4.400353642031277860310589091938627241607447857305708019118800e+118
db eval "SELECT $xf=\$x" : 0
expr { $xf == $x } : 1
db eval "SELECT $xf" = 4.4003536420313e+118
db eval "SELECT \$xf" = 4.4003536420313e+118
db eval "SELECT \$x" = 4.4003536420313e+118
db eval "CREATE TABLE t (a text, b real, c int)"
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.4003536420313e+118
values(c) = 1
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.4003536420313e+118
values(c) = 2
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.4003536420313e+118
values(c) = 3
values(*) = a b c
values(a) = 4.40035364203128e+118
values(b) = 4.4003536420313e+118
values(c) = 4
--------------------------------------------------------------------
On Fri, Mar 8, 2013 at 3:24 PM, Pavel Volkov <[email protected]> wrote:
> Excuse me, the test (test/atof1.test) of sqlite3 distribution, of
> course. It is guilty?
> Or tcl real to text conversation? Why only on the platform x32.
> Thanks.
>
> On Fri, Mar 8, 2013 at 3:10 PM, Richard Hipp <[email protected]> wrote:
>> On Fri, Mar 8, 2013 at 6:00 AM, Pavel Volkov <[email protected]> wrote:
>>
>>> And more tests. Perhaps one of the problems in converting real -> text?
>>>
>>
>> Binary to decimal conversion is *the* problem. TCL uses an infinite
>> precision integer math library to do exact binary to decimal conversion.
>> SQLite does not have access to such a library and so exact integer to
>> decimal conversion is beyond its reach.
>>
>> I repeat: SQLite stores and retrieves IEEE floating point values with
>> perfect accuracy. But it only does binary to decimal conversion of IEEE
>> floating point numbers with 14 or 15 digits of accuracy. If you need more
>> accuracy than this, use SQLite only for storage and use a different library
>> for your binary to decimal conversion.
>>
>>
>>
>> --
>> D. Richard Hipp
>> [email protected]
>> _______________________________________________
>> sqlite-users mailing list
>> [email protected]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users