Re: documentation error on https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/x86-Options.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/03/2018 09:09, Dennis Clarke wrote:

>      /* 128-bit floating point has at most 38 digits
>       *  of reasonable precision. We should be able to
>       *  load in a constant value for pi using :
>       *
>       *      3.1415926535 8979323846 2643383279
>       *        5028841971 6939937510
>       *
>       * The result should be a 16-byte big endian machines
>       * representation in memory thus :
>       *
>       *    40 00 92 1f b5 44 42 d1 8469 89 8c c5 17 01 b8
>       *
>       * We can try to load in some constants and hope we get
>       * a fully reasonable in memory value.
>       */

Oh, I didn't know about __float128.

https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html

$ cat float.c 
#include <stdio.h>
#include <string.h>

static __float128 pi = 3.1415926535897932384626433832795028841971693993751q;

#define N (sizeof pi)

int main(void)
{
	int i;
	unsigned char buf[N];

	memcpy(buf, &pi, N);
	for (i = 0; i < N; ++i) printf("%02x ", buf[i]);
	printf("\n");

	return 0;
}

$ gcc-7 -Wall -O2 float.c && ./a.out 
b8 01 17 c5 8c 89 69 84 d1 42 44 b5 1f 92 00 40 

(This is an amd64 little-endian system.)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux