Re: [sqlite] NaN in, 0.0 out?

2012-03-27 Thread Simon Slavin
On 27 Mar 2012, at 3:42am, "Jay A. Kreibich" wrote: > On Tue, Mar 27, 2012 at 03:30:03AM +0100, Simon Slavin scratched on the wall: >> >> On 27 Mar 2012, at 3:12am, Jay A. Kreibich wrote: >> >>> On Sun, Mar 25, 2012 at 05:48:01AM +0100, Simon Slavin scratched

Re: [sqlite] NaN in, 0.0 out?

2012-03-27 Thread Dominique Pellé
Francis J. Monari, Esquire wrote: > All, > > How are +infinity and -infinity handled? > > Frank. Don't forget signed zero, signaling and quiet NaN. Here is a short c++ programs to show how +infinity, -infinity zero, -zero, quiet NaN, signaling NaN are internally

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Nico Williams
On Mon, Mar 26, 2012 at 9:42 PM, Jay A. Kreibich wrote: > On Tue, Mar 27, 2012 at 03:30:03AM +0100, Simon Slavin scratched on the wall: >  Not do drag things out, but how would you "handle" a NaN?  If someone >  writes a signaling-NaN into the database, the DB will start to throw

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Jay A. Kreibich
On Tue, Mar 27, 2012 at 03:30:03AM +0100, Simon Slavin scratched on the wall: > > On 27 Mar 2012, at 3:12am, Jay A. Kreibich wrote: > > > On Sun, Mar 25, 2012 at 05:48:01AM +0100, Simon Slavin scratched on the > > wall: > > > >> Can those values be passed from a 'double' C

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Simon Slavin
On 27 Mar 2012, at 3:12am, Jay A. Kreibich wrote: > On Sun, Mar 25, 2012 at 05:48:01AM +0100, Simon Slavin scratched on the wall: > >> Can those values be passed from a 'double' C variable ? I believe so. >> So I see no reason why SQLite shouldn't be storing them. > > If, in

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Jay A. Kreibich
On Sun, Mar 25, 2012 at 05:48:01AM +0100, Simon Slavin scratched on the wall: > On 25 Mar 2012, at 3:48am, "Jay A. Kreibich" wrote: > > On Sat, Mar 24, 2012 at 07:32:32AM -0400, Richard Hipp scratched on the > > wall: > > > >> SQLite converts NaN inputs into NULL. > > > > I

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Simon Slavin
On 26 Mar 2012, at 4:58pm, Pavel Ivanov wrote: > SQLite version 3.7.5 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> create table t (n); > sqlite> insert into t values (1e305 * 1e305); > sqlite> insert into t values (-1e305 * 1e305);

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Pavel Ivanov
> Storing +infinity, for example.  It seems that in IEEE terms +infinity is > different from NaN, but SQLite return NULL in both instances. This is apparently some problem with your test setup. SQLite version 3.7.5 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Simon Slavin
On 26 Mar 2012, at 3:37pm, "Francis J. Monari, Esquire" wrote: > Storing +infinity, for example. It seems that in IEEE terms +infinity is > different from NaN, but SQLite return NULL in both instances. Oh dear. Where is the conversion happening ? Is the value stored

Re: [sqlite] NaN in, 0.0 out?

2012-03-26 Thread Francis J. Monari, Esquire
All, Storing +infinity, for example. It seems that in IEEE terms +infinity is different from NaN, but SQLite return NULL in both instances. Is there a standard "SQLite" style of handling this situation? Frank. Francis J. Monari, Esquire McKernan, McKernan & Godino 113 North Sixth Street

Re: [sqlite] NaN in, 0.0 out?

2012-03-25 Thread Jay A. Kreibich
On Sun, Mar 25, 2012 at 02:03:44PM -0400, Francis J. Monari, Esquire scratched on the wall: > All, > > Not to sound critical, but to be clear: using SQLite for IEEE > floating point will result in data "loss' unless precautions are > taken. Define "loss". SQLite, in general, is dependent on

Re: [sqlite] NaN in, 0.0 out?

2012-03-25 Thread Francis J. Monari, Esquire
All, Not to sound critical, but to be clear: using SQLite for IEEE floating point will result in data "loss' unless precautions are taken. Assuming my statement above is correct, then does a standard set of precautions exist? Frank. Francis J. Monari, Esquire McKernan, McKernan & Godino

Re: [sqlite] NaN in, 0.0 out?

2012-03-25 Thread Jay A. Kreibich
On Sun, Mar 25, 2012 at 09:29:58AM -0400, Francis J. Monari, Esquire scratched on the wall: > How are +infinity and -infinity handled? Generally, they are treated like normal values. You can calculate, store, and retrieve an INF or -INF value using just SQL expressions. As with all

Re: [sqlite] NaN in, 0.0 out?

2012-03-25 Thread Francis J. Monari, Esquire
All, How are +infinity and -infinity handled? Frank. Simon Slavin wrote: On 25 Mar 2012, at 3:48am, "Jay A. Kreibich" wrote: On Sat, Mar 24, 2012 at 07:32:32AM -0400, Richard Hipp scratched on the wall: SQLite converts NaN inputs into NULL. I think this is the right

[sqlite] NaN in, 0.0 out?

2012-03-25 Thread Stephan Buchert
Thanks for all the answers. The solution to check first the type with sqlite3_column_type() and, if NULL, return NaN seems the most practicable one from a user's standpoint. A future sqlite3_column_double_v2() or another way to control the conversion of non-numeric values to double would be nice

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24/03/12 21:48, Simon Slavin wrote: > But it's not what the docs say: NaN support changed in SQLite 3.5.9 (May 2008): http://www.sqlite.org/changes.html#version_3_5_9 However cvstrac no longer shows code so I couldn't work out if NaN was

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Simon Slavin
On 25 Mar 2012, at 3:48am, "Jay A. Kreibich" wrote: > On Sat, Mar 24, 2012 at 07:32:32AM -0400, Richard Hipp scratched on the wall: > >> SQLite converts NaN inputs into NULL. > > I think this is the right choice. It is what I would expect. But it's not what the docs say:

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Jay A. Kreibich
On Sat, Mar 24, 2012 at 07:32:32AM -0400, Richard Hipp scratched on the wall: > SQLite converts NaN inputs into NULL. I think this is the right choice. It is what I would expect. Well, no... what I would actually expect is that sqlite3_bind_double() should return an error, since it was

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Jean-Christophe Deschamps
Stephan, > Occasionally the sensor has a fault or the values are invalid (like > negative temperatures). To mark them once and for all as invalid, the > faulty values are replaced (in a C environment) by NaNs. Then the data are > inserted into the database with a C porgram, in a loop with the

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Richard Hipp
On Sat, Mar 24, 2012 at 3:18 AM, Stephan Buchert wrote: > Here the simplified scenario: > > We have measurements from a sensor array. The data are checked and plotted. > Then they are inserted into an SQLITE database. We find out that after > retrieving (selecting) the data

Re: [sqlite] NaN in, 0.0 out?

2012-03-24 Thread Simon Slavin
On 24 Mar 2012, at 7:18am, Stephan Buchert wrote: > Occasionally the sensor has a fault or the values are invalid (like > negative temperatures). To mark them once and for all as invalid, the > faulty values are replaced (in a C environment) by NaNs. Then the data are >

[sqlite] NaN in, 0.0 out?

2012-03-24 Thread Stephan Buchert
Here the simplified scenario: We have measurements from a sensor array. The data are checked and plotted. Then they are inserted into an SQLITE database. We find out that after retrieving (selecting) the data back from the database, the plots look different, the data have been changed! First we

[sqlite] NaN

2007-07-13 Thread Arun Bhalla
Last night I upgraded from SQLite 3.3.6 to SQLite 3.4.0. This morning a transaction in my application failed because SQLite detected that the application was trying to insert a row with a NULL in a REAL NOT NULL column. Actually, it turns out that it was a NaN, which SQLite 3.4.0 apparently