little/big endian conversions

Frank Benoit keinfarbton at googlemail.com
Wed Apr 9 03:57:52 PDT 2008


lurker schrieb:
> hi,
> 
> does anybody know how to convert float and doubles to little/big endian?
> 
> thanks

in tango there is the module tango.core.ByteSwap

The function
   static final void swap32 (void* dst, uint bytes);
can be used for one float or a float array.

float a;
swap32( &a, 4 );

float[10] b;
swap32( b.ptr, b.length*4 );

See
http://dsource.org/projects/tango/docs/current/tango.core.ByteSwap.html


More information about the Digitalmars-d-learn mailing list