https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107370

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I have to agree with Joseph (on x86_64-linux I get):
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>

int
main ()
{
  volatile _Float128 x = __builtin_sqrtf128(2.0f128);
  char buf[256];
  strfromf128 (buf, 128, "%a", x);
  strfromf128 (buf + 128, 128, "%.36f", x);
  printf ("%s\t%s\n", buf, buf + 128);
  x = x * x;
  strfromf128 (buf, 128, "%a", x);
  strfromf128 (buf + 128, 128, "%.36f", x);
  printf ("%s\t%s\n", buf, buf + 128);
  // The value you want to see
  x = 0x1.6a09e667f3bcc908b2fb1366dc6dp+0f128;
  strfromf128 (buf, 128, "%a", x);
  strfromf128 (buf + 128, 128, "%.36f", x);
  printf ("%s\t%s\n", buf, buf + 128);
  x = x * x;
  strfromf128 (buf, 128, "%a", x);
  strfromf128 (buf + 128, 128, "%.36f", x);
  printf ("%s\t%s\n", buf, buf + 128);
}

0x1.6a09e667f3bcc908b2fb1366ea95p+0     1.414213562373095048801688724209697984
0x1.ffffffffffffffffffffffffffffp+0     1.999999999999999999999999999999999807
0x1.6a09e667f3bcc908b2fb1366dc6dp+0     1.414213562373095048801688724209000027
0x1.ffffffffffffffffffffffffd7f4p+0     1.999999999999999999999999999998025537

Clearly the value GCC uses for sqrtf128(2.0f128) multiplied by itself is 1ulp
smaller than 2.0,
while the value you want to see is 10252ulps smaller than 2.0.

Reply via email to