### Re: sizeof (long double) vs sizeof (double)

Thomas Preud'homme <

robotux@...>

2014-09-18 14:37:17 GMT

Le dimanche 07 septembre 2014, 13:47:39 Mads a écrit :
> So basically, I should be able to get additional 2 bytes? And I suppose it
> will be stored as 12 bytes to maintain data structure alignment?
LDOUBLE_SIZE is defined to be 16 so you should have 16 bytes for long double
(twice that of double).
>
> Reading through the code as well as changelogs, x87 is indeed implemented,
> which means I should be able to use long double with higher precision than
> double.
> Correct me if I'm wrong, but shouldn't long double precision be like that
> declared in floats.h (see below ____i386____ / __x86___64____ ).
>
> (sorry for the hassle, but long double as extended precision is a necessary
> evil for me).
>
> *From include\floats.h*
> /* horrible intel long double */
> #if defined ____i386____ || defined __x86___64____
>
> #define LDBL_MANT_DIG 64
> #define LDBL_DIG 18
> #define LDBL_EPSILON 1.08420217248550443401e-19L
> #define LDBL_MIN_EXP (-16381)
> #define LDBL_MIN 3.36210314311209350626e-4932L
> #define LDBL_MIN_10_EXP (-4931)
> #define LDBL_MAX_EXP 16384
> #define LDBL_MAX 1.18973149535723176502e+4932L
> #define LDBL_MAX_10_EXP 4932
>
> #else
>
> /* same as IEEE double */
> #define LDBL_MANT_DIG 53
> #define LDBL_DIG 15
> #define LDBL_EPSILON 2.2204460492503131e-16
> #define LDBL_MIN_EXP (-1021)
> #define LDBL_MIN 2.2250738585072014e-308
> #define LDBL_MIN_10_EXP (-307)
> #define LDBL_MAX_EXP 1024
> #define LDBL_MAX 1.7976931348623157e+308
> #define LDBL_MAX_10_EXP 308
>
> #endif
Except these don't seem to be used in tcc's code. It's probably for system
headers only.
But I just tried compiling a similar testcase as yours and it gives the
correct sizeof (16). Can you show me the output of the configure script?
Best regards,
Thomas

Le dimanche 07 septembre 2014, 13:47:39 Mads a écrit :
> So basically, I should be able to get additional 2 bytes? And I suppose it
> will be stored as 12 bytes to maintain data structure alignment?
LDOUBLE_SIZE is defined to be 16 so you should have 16 bytes for long double
(twice that of double).
>
> Reading through the code as well as changelogs, x87 is indeed implemented,
> which means I should be able to use long double with higher precision than
> double.
> Correct me if I'm wrong, but shouldn't long double precision be like that
> declared in floats.h (see below ____i386____ / __x86___64____ ).
>
> (sorry for the hassle, but long double as extended precision is a necessary
> evil for me).
>
> *From include\floats.h*
> /* horrible intel long double */
> #if defined ____i386____ || defined __x86___64____
>
> #define LDBL_MANT_DIG 64
> #define LDBL_DIG 18
> #define LDBL_EPSILON 1.08420217248550443401e-19L
> #define LDBL_MIN_EXP (-16381)
> #define LDBL_MIN 3.36210314311209350626e-4932L
> #define LDBL_MIN_10_EXP (-4931)
> #define LDBL_MAX_EXP 16384
> #define LDBL_MAX 1.18973149535723176502e+4932L
> #define LDBL_MAX_10_EXP 4932
>
> #else
>
> /* same as IEEE double */
> #define LDBL_MANT_DIG 53
> #define LDBL_DIG 15
> #define LDBL_EPSILON 2.2204460492503131e-16
> #define LDBL_MIN_EXP (-1021)
> #define LDBL_MIN 2.2250738585072014e-308
> #define LDBL_MIN_10_EXP (-307)
> #define LDBL_MAX_EXP 1024
> #define LDBL_MAX 1.7976931348623157e+308
> #define LDBL_MAX_10_EXP 308
>
> #endif
Except these don't seem to be used in tcc's code. It's probably for system
headers only.
But I just tried compiling a similar testcase as yours and it gives the
correct sizeof (16). Can you show me the output of the configure script?
Best regards,
Thomas