On Mon, Feb 2, 2015 at 8:08 PM, Donald Shepherd <donald.sheph...@gmail.com>
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:
>
> SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
>   sqlite3VdbeMemSetNull(pMem);
>   if( !sqlite3IsNaN(val) ){
>     pMem->u.r = val;
>     pMem->flags = MEM_Real;
>   }
> }
>
> Richard answered on -0.0, i.e. it's a side effect of an optimization:
>

Someone mentioned the hardware representation of double & it being used in
the database. There are other formats in use, though the prevalence of the
x86 line of CPUs (particularly the 80387 coprocessor and the floating point
units included in 80486 & later chips [don't get me started on the 80486
SX, though]) have moved most of the world in the direction of the IEEE-754
1985 standard. Still, some processors don't have any floating point, some
have some type of fixed point, and yet others use completely different
binary representations of floating point numbers. Given how ubiquitous
IEEE-754 is in "modern" processors, I doubt there is anything in SQLite
that tries to accommodate any other floating point standards (though I
could be wrong).

If that is true (no other format support), the free SoftFloat library could
be used to provide floating point support on systems which do not support
IEEE-754 natively.

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

Reply via email to