I was amused by this:
http://www.steike.com/code/useless/evil-c/

I particularly liked the "internalEndianMagic".

I see this in some XML libs, as well as GMP and other open sourced code.

http://unix.derkeiler.com/Newsgroups/comp.unix.programmer/2005-12/msg00198.html


From:
https://svn.r-project.org/R/trunk/src/extra/trio/trionan.c

/*
 * Endian-agnostic indexing macro.
 *
 * The value of internalEndianMagic, when converted into a 64-bit
 * integer, becomes 0x0706050403020100 (we could have used a 64-bit
 * integer value instead of a double, but not all platforms supports
 * that type). The value is automatically encoded with the correct
 * endianess by the compiler, which means that we can support any
 * kind of endianess. The individual bytes are then used as an index
 * for the IEEE 754 bit-patterns and masks.
 */
#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])
static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275;
#endif

pretty weird stuff.

Reply via email to