On Thu, 2005-08-18 at 12:24 -0400, D. Richard Hipp wrote:
> On Thu, 2005-08-18 at 18:04 +0200, Frank van Vugt wrote:
> > L.S.
> > 
> > It looks like there's something wrong with the endiannes when using sqlite3 
> > (v3.2.2) on an ARM architecture (SA1100 nanoboard) while storing floating 
> > point data.
> > 
> 
> SQLite assumes float point values are stored in the IEEE 64-bit
> format with the same byte order as the machine integer.

I misspoke.

SQLite tries to store everything on disk as big-endian.  That
means it always byte swaps on little-endian machines (basically,
ix86) and omits byte swapping for big-endian machines (which is
to say, everything other than ix86.)  The byte swapping happens
for integers *and* floating-point numbers.

Here is the code that reads from the disk, for example.
buf[0]..buf[7] has been loaded with 8 bytes of floating point
or integer data taken from the disk.

    case 6:   /* 8-byte signed integer */
    case 7: { /* IEEE floating point */
      u64 x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
      u32 y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
      x = (x<<32) | y;
      if( serial_type==6 ){
        pMem->i = *(i64*)&x;
        pMem->flags = MEM_Int;
      }else{
        pMem->r = *(double*)&x;
        pMem->flags = MEM_Real;
      }

If this is incorrect, then I have a very serious problem...

-- 
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to