4 ms·
I encountered problems on some platforms in the 90s where zeroing the bits of an array of pointers or floats/doubles did not give you an array of NULL pointers
by vmilner 4y ago
I encountered problems on some platforms in the 90s where zeroing the bits of an array of pointers or floats/doubles did not give you an array of NULL pointers or 0.0 values. The comp.lang.c FAQ file discussed this in detail.
- debugnik 4y agoYeah, C doesn't require null pointers to be represented as 0, even if its constant is written 0, nor does it require floats/doubles to be represented as per IEEE-754. Or at least it didn't use to.
- deleted 4y ago[deleted]
- mgaunard 4y agoI don't think that's standards compliant. At least for floating-point, not entirely sure about pointers.
- vmilner 4y agoYes. I was porting code to new machines and programmers had assumed it was compliant but it wasn’t.
- leni536 4y agofloats being IEEE compliant is optional by the language standards. Otherwise the bit representation is not specified.
- deleted 4y ago[deleted]
- mgaunard 4y agoIt still requires 0 to be represented as all bits set to zero.
- leni536 4y agoWhere does the ISO C standard say so? edit: https://cigix.me/c17#6.2.6.1.p1 https://cigix.me/c17#6.2.6.1.p1 seems relevant, I did not find anything for floating point types. edit2: Notes are probably not normative, but still: https://cigix.me/c17#footnote301 https://cigix.me/c17#footnote301
- vmilner 4y agoThat footnote confirms the traditional position that a floating point zero need NOT have an all-zero bit representation.