Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How would the compiler be able to use any fast, floating point specific instructions if you parsed it as a hexadecimal string?


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/


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: