4 ms·
IIRC the latest C standards adopted the union trick for type punning; it is the only correct way to access floating-point as int, or create an array of function
by xenadu02 8y ago
IIRC the latest C standards adopted the union trick for type punning; it is the only correct way to access floating-point as int, or create an array of function pointers of different types.
(The latter is not something I've seen any compiler ever exploit though)
- saagarjha 8y ago> it is the only correct way to access floating-point as int Well, other than memcpy. And it's kinda sketchy in the way that they did it: it was a tacked-on footnote in the C99 standard retained through to C11. > create an array of function pointers of different types Well, void * * or char * * (spaces so Hacker News doesn’t eat it) would do just as well…
- Asooka 8y agoWhat about the latest C++ standards :) ?