Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -1209,23 +1209,37 @@ case OF_NUMBER_PTRDIFF: case OF_NUMBER_INTPTR:; [element addAttributeWithName: @"type" stringValue: @"signed"]; break; - case OF_NUMBER_FLOAT: + case OF_NUMBER_FLOAT:; + union { + float f; + uint32_t i; + } f; + + f.f = value.float_; + [element addAttributeWithName: @"type" stringValue: @"float"]; [element setStringValue: - [OFString stringWithFormat: @"%" PRIX32, - *(uint32_t*)&value.float_]]; + [OFString stringWithFormat: @"%" PRIX32, f.i]]; + break; - case OF_NUMBER_DOUBLE: + case OF_NUMBER_DOUBLE:; + union { + double d; + uint64_t i; + } d; + + d.d = value.double_; + [element addAttributeWithName: @"type" stringValue: @"double"]; [element setStringValue: - [OFString stringWithFormat: @"%" PRIX64, - *(uint64_t*)&value.double_]]; + [OFString stringWithFormat: @"%" PRIX64, d.i]]; + break; default: @throw [OFInvalidFormatException newWithClass: isa]; } Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -208,19 +208,33 @@ #endif static OF_INLINE float OF_CONST_FUNC of_bswap_float(float f) { - uint32_t tmp = of_bswap32(*(uint32_t*)&f); - return *(float*)&tmp; + union { + float f; + uint32_t i; + } u; + + u.f = f; + u.i = of_bswap32(u.i); + + return u.f; } static OF_INLINE double OF_CONST_FUNC of_bswap_double(double d) { - uint64_t tmp = of_bswap64(*(uint64_t*)&d); - return *(double*)&tmp; + union { + double d; + uint64_t i; + } u; + + u.d = d; + u.i = of_bswap64(u.i); + + return u.d; } static OF_INLINE void of_bswap32_vec(uint32_t *buffer, size_t length) {