]> gitweb.factorcode.org Git - factor.git/blob - basis/math/floats/half/half-tests.factor
use radix literals
[factor.git] / basis / math / floats / half / half-tests.factor
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
5
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
13
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
19
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
23
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
32
33 STRUCT: halves
34     { tom half }
35     { dick half }
36     { harry half }
37     { harry-jr half } ;
38
39 [ 8 ] [ halves heap-size ] unit-test
40
41 [ 3.0 ] [
42     halves <struct>
43         3.0 >>dick
44     dick>>
45 ] unit-test
46
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
49