Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work out why host validation on sqrt fails (float128) #24

Open
florianschanda opened this issue May 29, 2020 · 0 comments
Open

work out why host validation on sqrt fails (float128) #24

florianschanda opened this issue May 29, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@florianschanda
Copy link
Owner

florianschanda commented May 29, 2020

The following program produces an off-by-one error:

#include <quadmath.h>
#include <stdio.h>
#include <stdint.h>

int main()
{
  union {
    __float128 f;
    uint32_t bv[2];
  } data;
  union {
    __float128 f;
    uint32_t bv[2];
  } result;
  char tmp[256];

  data.bv[3] = 0x000064B5;
  data.bv[2] = 0x59A3D7F7;
  data.bv[1] = 0x56924E4F;
  data.bv[0] = 0xE681141C;

  quadmath_snprintf(tmp, sizeof(tmp), "%Qa", data.f);
  printf("Input: %s\n", tmp);

  result.f = sqrtq(data.f);

  quadmath_snprintf(tmp, sizeof(tmp), "%Qa", result.f);
  printf("Output: %s\n", tmp);

  printf("As BV: 0x");
  for (int i=3; i>=0; --i) {
    printf("%08x", result.bv[i]);
  }
  printf("\n");
}

The result should be: 0x1FFF4121A5EFB86CD358C0F1BA4AE60B
However we're getting: 0x1FFF4121A5EFB86CD358C0F1BA4AE60C

@florianschanda florianschanda added the bug Something isn't working label May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant