kwhatmough
08-08-2008, 05:33 PM
In a previous post I refer to one of the well-known IEEE floating-point 'hacks' in which you alias (or union) a float and an int so that you can apply integer bit-fiddling tricks which tend to be faster than the equivalent conditional branching.
http://www.devmaster.net/forums/showthread.php?t=12680
In general I _think_ that the IEEE 754 representation is almost ubiquitous these days. However, should one be concerned about potential issues with endian-ness when using a method like this? Apparently the endian-ness of the memory representation is not part of the IEEE specification:
Endianness – Wikipedia (http://en.wikipedia.org/wiki/Endianness#Floating-point_and_endianness)
although I would like to think that the endian-ness of the float representation is consistent with the endian-ness of the corresponding integer representation. Perhaps it is only a potential issue when dealing with (64-bit) doubles and longs, as opposed to (32-bit) float and int(?)
<Assume here that we want the code to be portable at least to PC, Mac, and perhaps the major game consoles>.
http://www.devmaster.net/forums/showthread.php?t=12680
In general I _think_ that the IEEE 754 representation is almost ubiquitous these days. However, should one be concerned about potential issues with endian-ness when using a method like this? Apparently the endian-ness of the memory representation is not part of the IEEE specification:
Endianness – Wikipedia (http://en.wikipedia.org/wiki/Endianness#Floating-point_and_endianness)
although I would like to think that the endian-ness of the float representation is consistent with the endian-ness of the corresponding integer representation. Perhaps it is only a potential issue when dealing with (64-bit) doubles and longs, as opposed to (32-bit) float and int(?)
<Assume here that we want the code to be portable at least to PC, Mac, and perhaps the major game consoles>.