upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYash Dubey <yash.dubey803at@gmail.com>2026-11-24 07:37:00 +0530
committerYash Dubey <yash.dubey803at@gmail.com>2026-11-24 08:26:53 +0530
commit4e8aa910feb63fbf2d9beb621bbd7bae2fae51b2 (patch)
treee927ba522649a55c1c2108147eba472c670b9d3c /tests
parentba49ba26a1013c5977c11037457a05bccbe203f0 (diff)
spirv_asm: a decimal f32 constant is rounded once, and an f16 one is that f32 cut toward zero, as spirv-as reads them
Diffstat (limited to 'tests')
-rw-r--r--tests/test_spirv_asm.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_spirv_asm.py b/tests/test_spirv_asm.py
index 54ca1b7ba..fe3bef39a 100644
--- a/tests/test_spirv_asm.py
+++ b/tests/test_spirv_asm.py
@@ -740,6 +740,23 @@ class FloatLiteralTests(unittest.TestCase):
740 ("f64", "0x1.fffffffffffff8p1023", [0xFFFFFFFF, 0x7FEFFFFF]), 740 ("f64", "0x1.fffffffffffff8p1023", [0xFFFFFFFF, 0x7FEFFFFF]),
741 )) 741 ))
742 742
743 def test_decimal_is_rounded_once_to_f32_and_f16_narrows_that_toward_zero(self):
744 # old #3911 (@lumenpearson): each of these decimals reads as a double on an f32 tie, which rounding the double
745 # again broke the wrong way; strtof rounds the decimal once. A 16-bit decimal is that f32 cut toward zero.
746 self._check((
747 ("f32", "1.00000005960464477539062500000001", [0x3F800001]),
748 ("f32", "-1.00000005960464477539062500000001", [0xBF800001]),
749 ("f32", "1.000000059604644775390625", [0x3F800000]),
750 ("f32", "1.00000017881393432617187499999999", [0x3F800001]),
751 ("f32", "1.000000178813934326171875", [0x3F800002]),
752 ("f32", "7.00649232162408535461864791644958065640130970938257885878534141944895541342930300743319094181060791"
753 "015625000001e-46", [0x00000001]),
754 ("f32", "0.1", [0x3DCCCCCD]), ("f32", "3.4028235e38", [0x7F7FFFFF]), ("f32", "-0.0", [0x80000000]),
755 ("f16", "1.0006", [0x3C00]), ("f16", "-1.0006", [0xBC00]), ("f16", "65535", [0x7BFF]),
756 ("f16", "5e-8", [0x0000]), ("f16", "0.1", [0x2E66]), ("f16", "1.5", [0x3E00]),
757 ("f64", "0.1", [0x9999999A, 0x3FB99999]),
758 ))
759
743 760
744if __name__ == "__main__": 761if __name__ == "__main__":
745 unittest.main() 762 unittest.main()