News for hackers. Stuff that matters.
Re:Parsing can become accidentally quadratic because of sscanf by adrian_b on Monday March 01, 2021 @12:02PM (#26304958)
Whenever floating-point numbers converted to text are not intended to be used by a human, converting the numbers to decimal is a great mistake in my opinion.

The floating-point numbers should be converted to text as hexadecimal, e.g., in C99 and later, using printf with the %a or %A conversion specifiers.

Even when a human uses the textual floating-point numbers, if they are used only for making copies or comparisons, the hexadecimal numbers are more convenient and they are free of conversion errors.

Re:Parsing can become accidentally quadratic because of sscanf by orf on Monday March 01, 2021 @02:27PM (#26307080)
How would the compiler be able to use any fast, floating point specific instructions if you parsed it as a hexadecimal string?
Re:Parsing can become accidentally quadratic because of sscanf by MauranKilom on Monday March 01, 2021 @03:33PM (#26308012)
Not sure I understand the question. The suggestion is to use hexfloats, as they are unambiguous and straightforward to convert from and to (as opposed to anything with decimal significands): https://www.cplusplus.com/reference/ios/hexfloat/
Re:Parsing can become accidentally quadratic because of sscanf by firebacon on Monday March 01, 2021 @03:43PM (#26308124)
You don't need any specific instructions. The hex encoded double contains the final binary representation of the floating point number. So no conversion is required to load it, except maybe for swapping around bytes on some architectures. Conceptually:

    double v;
    memcpy(&v, "\x00\x00\x00\x00\x00\xe4\x94\x40", sizeof(v)); // LE