Long double versus double

I know that the size of various data types can vary depending on which system I am on. I am using XP 32bits and using the sizeof () operator in C ++, it seems that long double is 12 bytes and double is 8.

However, most major sources claim that long double is 8 bytes, so the range is the same as double.

Where do I get 12 bytes? If a long double really is 12 bytes, doesn't that expand the range of values? Or is a long signature used only (compiler digits) when the value exceeds the range of the double and, therefore, goes beyond 8 bytes?

Thank.

+42
c ++ floating-point long-double
Aug 11 '10 at 0:55
source share
3 answers

Quote from Wikipedia :

In x86 architecture, most compilers implement long double as an 80-bit extended precision type supported by this equipment (sometimes stored as 12 or 16 bytes to support the data structure.

and

Compilers can also use long double for the 128-bit four-time precision format that is currently implemented in software.

In other words, yes, a long double can store a wider range of values ​​than a double . But it depends entirely on the compiler.

+47
Aug 11 2018-10-11T00:
source share

As for my newbie programming, tell me:

  • Use periodic normalized float [-1.0, + 1.0]

  • Hold the normalizing value separately with double or long double

  • Normalization introduces noise = small errors = high frequencies to variable values

  • From time to time, it is useful to normalize while preserving the median value separately and save data sorting (the original data order can be saved as a permutation vector)

+2
Sep 22 '17 at 15:01
source share

Standard byte sizes for numbers are guaranteed minimum sizes on all platforms. They may be larger on some systems, but they will never be smaller.

+1
Aug 11 '10 at 1:12
source share



All Articles