1 USING: accessors alien.c-types alien.syntax math.floats.half kernel
2 math tools.test specialized-arrays alien.data classes.struct ;
3 SPECIALIZED-ARRAY: half
4 IN: math.floats.half.tests
6 { 0x0000 } [ 0.0 half>bits ] unit-test
7 { 0x8000 } [ -0.0 half>bits ] unit-test
8 { 0x3e00 } [ 1.5 half>bits ] unit-test
9 { 0xbe00 } [ -1.5 half>bits ] unit-test
10 { 0x7c00 } [ 1/0. half>bits ] unit-test
11 { 0xfc00 } [ -1/0. half>bits ] unit-test
12 { 0x7eaa } [ NAN: aaaaaaaaaaaaa half>bits ] unit-test
14 ! too-big floats overflow to infinity
15 { 0x7c00 } [ 65536.0 half>bits ] unit-test
16 { 0xfc00 } [ -65536.0 half>bits ] unit-test
17 { 0x7c00 } [ 131072.0 half>bits ] unit-test
18 { 0xfc00 } [ -131072.0 half>bits ] unit-test
20 ! too-small floats flush to zero
21 { 0x0000 } [ 1.0e-9 half>bits ] unit-test
22 { 0x8000 } [ -1.0e-9 half>bits ] unit-test
24 { 0.0 } [ 0x0000 bits>half ] unit-test
25 { -0.0 } [ 0x8000 bits>half ] unit-test
26 { 1.5 } [ 0x3e00 bits>half ] unit-test
27 { -1.5 } [ 0xbe00 bits>half ] unit-test
28 { 1/0. } [ 0x7c00 bits>half ] unit-test
29 { -1/0. } [ 0xfc00 bits>half ] unit-test
30 { 3.0 } [ 0x4200 bits>half ] unit-test
31 { t } [ 0x7e00 bits>half fp-nan? ] unit-test
39 { 8 } [ halves heap-size ] unit-test
47 { half-array{ 1.0 2.0 3.0 1/0. -1/0. } }
48 [ { 1.0 2.0 3.0 1/0. -1/0. } half >c-array ] unit-test