mercredi 22 avril 2020

C++11: Print `double` as hex?

I need to print a IEEE 64-bit double as hex string.

  • I understand I have to use std::hexfloat in some way. But how to get the state of the stream right before that so it can be reset to the initial state?

  • Must the precision also be hacked if the goal is to print with the highest possible precision? Or is that already a feature of hexfloat?

  • The output must be in such a way that it can be used in a C/C++ source without any further ado, e.g. -0x123.abc42p+10.

The language I am using is C++11. Not more, not less.

Aucun commentaire:

Enregistrer un commentaire