I wrote a small program to see how my computer stores floating point numbers (this is on macOS Big Sur), and results looked like this:
Float value = 2.000000
Memory representation: 00000000 00000000 00000000 01000000
Float value = 4.000000
Memory representation: 00000000 00000000 10000000 01000000
Float value = 8.000000
Memory representation: 00000000 00000000 00000000 01000001
Float value = 16.000000
Memory representation: 00000000 00000000 10000000 01000001
Float value = 32.000000
Memory representation: 00000000 00000000 00000000 01000010
I believe I am printing out the bits correctly, so my question is how is macOS storing each part of the floating point number? Meaning how should each of these bit strings be divided into the exponent, fractional part, and sign? It also looks like the sign bit is stored at the beginning of the last byte, rather than at the beginning of the first byte like I was expecting:
Float value = 2.000000
Memory representation: 00000000 00000000 00000000 01000000
Float value = -2.000000
Memory representation: 00000000 00000000 00000000 11000000