Why is real.sizeof == 16 on x86-systems?!?
Its the IEEE 754 extended format: 64bit mantissa + 15bit exponent + sign.
It should be size 10!
I mean, alignment may be different, but why wasting so much memory even in arrays?
Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 05 real.sizeof | ||||
---|---|---|---|---|
| ||||
February 05 Re: real.sizeof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dom DiSc | On Monday, 5 February 2024 at 16:45:03 UTC, Dom DiSc wrote: >Why is real.sizeof == 16 on x86-systems?!? According to the language spec, You can verify this by compiling the following test program:
On my laptop (Linux, x86_64), compiling this program with
|
February 05 Re: real.sizeof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dom DiSc | On Monday, 5 February 2024 at 16:45:03 UTC, Dom DiSc wrote: >Why is real.sizeof == 16 on x86-systems?!? Padding. x86 ABI prefers things to be aligned, so on x86 it's 12 bytes, x86_64 16 bytes. In both cases you don't get any extra precision over the 80-bits that x87 gives you. |
February 05 Re: real.sizeof | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Monday, 5 February 2024 at 17:28:38 UTC, Iain Buclaw wrote: >Padding. x86 ABI prefers things to be aligned, so on x86 it's 12 bytes, x86_64 16 bytes. In both cases you don't get any extra precision over the 80-bits that x87 gives you. This is exactly what I mean. The ABI may pad it, but sizeof should still give the number of bytes that are really used (not counting the gaps). In my code I wanted do decide if the processor uses double-extended or quadruple as real depending on the sizeof. At least in an array of real I would expect no padding, like in an array of bool (except for odd length). |