Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-02-02 Thread Scott Robison
On Mon, Feb 2, 2015 at 8:08 PM, Donald Shepherd wrote: > sqlite3_bind_double calls sqlite3VdbeMemSetDouble which has a specific > check against NaN. My assumption is that this is what results in NaNs not > round tripping and instead coming back out as SQLITE_NULL: > >

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-02-02 Thread Donald Shepherd
On Tue Feb 03 2015 at 12:23:29 PM James K. Lowden wrote: > On Sun, 1 Feb 2015 02:13:15 +0100 > Stephan Beal wrote: > > > On Sun, Feb 1, 2015 at 2:07 AM, Simon Slavin > > wrote: > > > > > So, having established that NaN and

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-02-02 Thread James K. Lowden
On Sun, 1 Feb 2015 02:13:15 +0100 Stephan Beal wrote: > On Sun, Feb 1, 2015 at 2:07 AM, Simon Slavin > wrote: > > > So, having established that NaN and -0 do not make the round trip > > from a C variable through a database and back into a C variable

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-31 Thread Stephan Beal
On Sun, Feb 1, 2015 at 2:07 AM, Simon Slavin wrote: > So, having established that NaN and -0 do not make the round trip from a C > variable through a database and back into a C variable ... at least I think > we have ... > If you're assuming C89 (which sqlite3 is, by and

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-31 Thread Simon Slavin
On 31 Jan 2015, at 11:14pm, James K. Lowden wrote: > That said, https://www.sqlite.org/datatype3.html says REAL is "stored > as an 8-byte IEEE floating point number". I can't see why a > non-signalling NaN couldn't be stored and interpreted. You'd need some >

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-31 Thread James K. Lowden
On Fri, 30 Jan 2015 10:39:31 +0200 RSmith wrote: > At first I thought SQLite (or any RDBMS) should really strore > whatever you give and return it untouched, but that cannot be true > for an RDBMS because it has to interpret the data, it isn't just a > binary store. It has to

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-30 Thread Stephan Beal
On Fri, Jan 30, 2015 at 3:45 AM, Donald Shepherd wrote: > I'm still not convinced whether it's the behaviour causing my problem, but > it does look like negative zero is another special case: > > SQLite version 3.8.7.2 2014-11-18 20:57:56 > Enter ".help" for usage

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-30 Thread RSmith
On 2015/01/30 05:49, Donald Shepherd wrote: Trying to retrieve a stored qNaN or sNaN returns a column type of NULL and a value of 0. Thank you for letting us know. Well I suppose that's SQLite's method to answer with errors of the sort, returning NULL (as is the case with div0 for

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-29 Thread Donald Shepherd
Trying to retrieve a stored qNaN or sNaN returns a column type of NULL and a value of 0. On Thu Jan 29 2015 at 8:56:35 PM RSmith wrote: > > On 2015/01/29 05:05, James K. Lowden wrote: > > There's no reason to think, if the data are provided in binary form, > that they won't

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-29 Thread Richard Hipp
On 1/29/15, Donald Shepherd wrote: > I'm still not convinced whether it's the behaviour causing my problem, but > it does look like negative zero is another special case: > > SQLite version 3.8.7.2 2014-11-18 20:57:56 > Enter ".help" for usage hints. > sqlite> create

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-29 Thread Donald Shepherd
I'm still not convinced whether it's the behaviour causing my problem, but it does look like negative zero is another special case: SQLite version 3.8.7.2 2014-11-18 20:57:56 Enter ".help" for usage hints. sqlite> create table datatable2 (doublevalue real); sqlite> insert into datatable2

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-29 Thread Keith Medcalf
>I wonder what happens if you put SQLite on a computer with no native IEEE >maths library. Same as compiling with SQLITE_OMIT_FLOATING_POINT on a computer/compiler that *does* have floating point I should imagine -- you end up with a version of SQLite with all floating point omitted. ---

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-29 Thread RSmith
On 2015/01/29 05:05, James K. Lowden wrote: There's no reason to think, if the data are provided in binary form, that they won't be returned in the identical form absent an explicit conversion. If that's not so, I'd sure like to know why. I'm faintly surprised NaNs can't be stored, too. Why

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Igor Tandetnik
On 1/28/2015 10:05 PM, James K. Lowden wrote: I'm faintly surprised NaNs can't be stored, too. Why should SQLlite interpret them if they're bound to a double? Signaling NaN may trigger a hardware exception (aka a signal) merely by being loaded into an FPU register (that's what makes it

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Simon Slavin
On 29 Jan 2015, at 3:05am, James K. Lowden wrote: > We can make stronger statements than that, can't we? It's not like > there's some mystery about it: database and memory share a single > floating-point format. > > If the caller uses _bind_double and

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread James K. Lowden
On Wed, 28 Jan 2015 23:09:21 + Simon Slavin wrote: > > This is a bit of a speculative question related to a problem I'm > > having - are there legal values of a C++ double that would get > > truncated when written into and read from an SQLite database? > > In theory

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Donald Shepherd
Thanks for the reassurances. I have a case where differences in doubles would explain what I'm seeing but I have no evidence that it is the case (evidence compilation is still underway), hence my attempt to plumb the depths of the list's knowledge to see if there was any known edge cases to be

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Simon Slavin
On 28 Jan 2015, at 10:47pm, Donald Shepherd wrote: > This is a bit of a speculative question related to a problem I'm having - > are there legal values of a C++ double that would get truncated when > written into and read from an SQLite database? In theory there

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread RSmith
On 2015/01/29 01:00, Donald Shepherd wrote: I can say there's no string round-trips with fairly high confidence and I am using _bind_double and _column_double. I can also confirm NaNs are a special case, as I've had to write code to store those as a BLOB. So you have a case where you have a

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Donald Shepherd
I can say there's no string round-trips with fairly high confidence and I am using _bind_double and _column_double. I can also confirm NaNs are a special case, as I've had to write code to store those as a BLOB. On Thu Jan 29 2015 at 9:57:14 AM Igor Tandetnik wrote: > On

Re: [sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Igor Tandetnik
On 1/28/2015 5:47 PM, Donald Shepherd wrote: This is a bit of a speculative question related to a problem I'm having - are there legal values of a C++ double that would get truncated when written into and read from an SQLite database? Written into and read from how, exactly? Do they, say,

[sqlite] Truncation of floating point numbers in SQLite?

2015-01-28 Thread Donald Shepherd
This is a bit of a speculative question related to a problem I'm having - are there legal values of a C++ double that would get truncated when written into and read from an SQLite database? The column is specified as having REAL affinity though I gather that shouldn't matter.