Given the following code snippet:
Code:
unsigned long long x;
x = (0 ? (double) 0 : 0xf1debc9a78563412ULL);
On GCC 4.5.0 on a i686 mingw32_NT-5.1 I get the result 0xf1debc9a78563800. It appears the constant value is being converted to a double then back to an unsigned long long. Is this a feature or a bug? If you ask why this is useful I was trying to use it as part of size independent byte swap macro:
Code:
#define _floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
#define BSWAP(x, type) \
(_floating_type (type) && (sizeof (type) == sizeof (float)) ? bswap_float (x) : \
(_floating_type (type) && (sizeof (type) == sizeof (double)) ? bswap_double (x) : \
(sizeof (type) == sizeof (uint8_t) ? (x) : \
(sizeof (type) == sizeof (uint16_t) ? bswap16 (x) : \
(sizeof (type) == sizeof (uint32_t) ? bswap32 (x) : \
(sizeof (type) == sizeof (uint64_t) ? bswap64 (x) : (1/0))))))))