On Friday 07 November 2014 09:24:44 Linus Torvalds wrote:
> On Nov 7, 2014 8:23 AM, "John Van Ostrand" <[email protected]> wrote:
> > Are floats portable enough to reference directly, like this:
> > 
> > start_cns = *(float *) buf;
> 
> Aside from byte ordering and alignment, generally yes. There are some
> random small details like denormals that different architecture might
> handle differently (round to zero etc), but that won't be an issue for any
> dive data.

To avoid the alignment issue, write:

        memcpy(&start_cns, buf, sizeof start_cns);

On a platform where alignment is not an issue, the compiler will optimise the 
memcpy away and will do exactly what you had written above.

> And in theory other representations than just the standard IEEE one exists,
> but in practice no current hardware uses it, so it's not worth worrying
> about.

And in practice Subsurface does not run on platforms where alignment is an 
issue either, especially not desktop Subsurface. I think the both Android and 
iOS put their ARM processors in unaligned mode, allowing unaligned loads, but 
it would be nice to get confirmation.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to