IEEE 754 defines the bit pattern that are used to represent certain numbers (and not even that completely, like endianness) and how operations with those numbers should work. It doesn't define any string representations for said numbers, that's left up to implementations. And the only thing you're testing here is that printf() implementation.
IEEE 754 says that -0 and 0 should be equal, so omitting the minus here is reasonable.
I have no idea who even came up with "-nan", it's certainly never used anywhere in the standard, which calls them quiet/signaling NaN. The C standard also seems considers a separate representation for signaling NaNs optional and implementation defined:
These are definitely not correct though, they should be printing nan. But since it works on the RP2350 I guess it isn't a problem with the printf() implementation directly? Not sure if the RP2040 soft float is the problem here or something else, would need to dig deeper.
Code:
80000000 is 0.000000<--- Should be -0.000000FF80FFFF is nan<--- Should be -nanI have no idea who even came up with "-nan", it's certainly never used anywhere in the standard, which calls them quiet/signaling NaN. The C standard also seems considers a separate representation for signaling NaNs optional and implementation defined:
For a signaling NaN value, the implementation has the options to trigger the signaling NaN or to convert it in one of the styles [-]nan(sig) or [-]nans(sign-char-sequence) -- which style, and the interpretation of any n-char sequence, is implementation-defined.
Code:
7FF000000000FFFF is inf<--- Should be nanFFF000000000FFFF is -inf<--- Should be -nanStatistics: Posted by Tharre — Tue Jul 29, 2025 4:04 pm