4 ms·
Its not, union is valid in C(note, not c++) for this.
by Cloudef 5y ago
Its not, union is valid in C(note, not c++) for this.
- nly 5y agoIt is probably still unwise in C as well in this case because the layout of bits in a bitfield is still implementation defined, and varied based on endianness of the uint64 for example
- occamrazor 5y agoWhat is the alternative? Are there functions in the C standard to get mantissa and exponent?
- gpderetta 5y agoFrexp modf. Last time I checked code generation wasn't particularly good.
- CyberRabbi 5y agoI already mentioned the alternative. memcpy() into a char array.
- Cloudef 5y agoMemcpy doesnt fix endianess
- CyberRabbi 5y agoIt was never claimed to deal with endianness and while we're on the subject of binary-layout, union-based binary manipulation is even worse on that front as no specific binary layout is mandated for structures or floating points.
- CyberRabbi 5y agolemire's code is C++