I have to print the binary representation of a long double
number for some reasons. I want to see the exact format as it remains in the computer memory.
I went through the following questions where taking a union
was the the solution. For float
, alternate datatype was unsigned int
as both are 32-bit. For double
, it was unsigned long int
as both are 64-bit. But in of long double
, it is 96-bit/128-bit (depending on platform) which has no similar equivalent memory consumer. So, what would be the solution?
Visited Questions:
- Print binary representation of a float number in C++
- Binary representation of a double
- Exact binary representation of a double
- How do I display the binary representation of a float or double?
ATTENTION:
It is marked as duplicate of the question How to print (using cout) the way a number is stored in memory? !
Really is it? The question mentioned question talked about integer number and accepted solution of it was bitset
which just truncates the floating-point part. My main point of view is floating-point representation which has no relation with the content of that question.