Advertisement
Guest User

Zig sparc64 float weirdness

a guest
Nov 29th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. E.g, the first three entries of lookup_table in lib/std/fmt/errol/lookup.zig:
  2. pub const lookup_table = [_]HP{
  3. HP{ .val = 1.000000e+308, .off = -1.097906362944045488e+291 },
  4. HP{ .val = 1.000000e+307, .off = 1.396894023974354241e+290 },
  5. HP{ .val = 1.000000e+306, .off = -1.721606459673645508e+289 },
  6.  
  7. This compiles down to the following (correct) assembly when cross-built on
  8. an x64 machine using `-target sparcv9-linux-gnu`:
  9. lookup_table:
  10. .xword 0x7fe1ccf385ebc8a0 ! double 1.0E+308
  11. .xword 0xfc5c2a3c3d855605 ! double -1.0979063629440455E+291
  12. .xword 0x7fac7b1f3cac7433 ! double 9.9999999999999999E+306
  13. .xword 0x7c2cab0301fbbb2f ! double 1.3968940239743542E+290
  14. .xword 0x7f76c8e5ca239029 ! double 1.0E+306
  15. .xword 0xfbfc43fd98036a41 ! double -1.7216064596736455E+289
  16.  
  17. But compiles down to the wrong values when built natively on a sparc64 machine:
  18. lookup_table:
  19. .xword 0x46f1ccf385ebc8a0 ! double 5.7766220027674547E+33
  20. .xword 0xc6fc2a3c3d855605 ! double -9.1400591232411468E+33
  21. .xword 0x46fc7b1f3cac7433 ! double 9.2425952044279273E+33
  22. .xword 0x46fcab0301fbbb2f ! double 9.3033026487185308E+33
  23. .xword 0x46f6c8e5ca239029 ! double 7.3940761635423421E+33
  24. .xword 0xc6fc43fd98036a41 ! double -9.172707828336624E+33
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement