Increment version to 0.7.9 to send to Translation Project.
[pspp-builds.git] / tests / libpspp / float-format.at
1 AT_BANNER([floating point formats])
2
3 AT_SETUP([floating point format conversions])
4 AT_DATA([float-format.txt], [dnl
5 # Each of the tests below checks that conversion between
6 # floating-point formats works correctly.  Comparisons that use ==
7 # require that conversion from any format on the line to any other
8 # format on the line work losslessly.  Comparisons that use => only
9 # check that conversions work losslessly in the given direction.
10
11 # Key to format names:
12 # isl: IEEE single-precision, little endian
13 # isb: IEEE single-precision, big endian
14 # idl: IEEE double-precision, little endian
15 # idb: IEEE double-precision, big endian
16 # vf: VAX F
17 # vd: VAX D
18 # vg: VAX G
19 # zs: Z architecture short
20 # zl: Z architecture long
21 # x: hexadecimal digits
22
23 # IEEE special values.
24  0 == isb('00000000')
25 x('Infinity') == isb('7f800000')
26 x('-Infinity') == isb('ff800000')
27 x('NaN:') => isb('7f800001')            # NaN requires nonzero fraction.
28 x('NaN:e000000000000000') == isb('7ff00000') == idb('7ffe000000000000')
29 x('NaN:5a5a5e0000000000') == isb('7fad2d2f') == idb('7ff5a5a5e0000000')
30 x('NaN:975612abcdef4000') == idb('7ff975612abcdef4')
31 x('-NaN:e000000000000000') == isb('fff00000') == idb('fffe000000000000')
32 x('-NaN:5a5a5e0000000000') == isb('ffad2d2f') == idb('fff5a5a5e0000000')
33 x('-NaN:975612abcdef4000') == idb('fff975612abcdef4')
34
35 # PSPP special values.
36 x('Missing') == isb('ff7fffff') == idb('ffefffffffffffff') == isl('ffff7fff') == idl('ffffffffffffefff') == vf('ffffffff') == vd('ffffffffffffffff') == vg('ffffffffffffffff') == zs('ffffffff') == zl('ffffffffffffffff')
37 x('Lowest') == isb('ff7ffffe') == idb('ffeffffffffffffe') == isl('feff7fff') == idl('feffffffffffefff') == vf('fffffeff') == vd('fffffeffffffffff') == vg('fffffeffffffffff') == zs('fffffffe') == zl('fffffffffffffffe')
38 x('Highest') == isb('7f7fffff') == idb('7fefffffffffffff') == isl('ffff7f7f') == idl('ffffffffffffef7f') == vf('ff7fffff') == vd('ffffffffff7fffff') == vg('ffffffffff7fffff') == zs('7fffffff') == zl('7fffffffffffffff')
39
40 # From Wikipedia.
41 0.15625 == isb('3e200000')
42 -118.625 == isb('c2ed4000')
43
44 # http://www.psc.edu/general/software/packages/ieee/ieee.html
45 x('NaN:0400000000000000') == isb('7f820000')
46 x('-NaN:2225540000000000') == isb('ff9112aa')
47 2 == isb('40000000')
48 6.5 == isb('40d00000')
49 -6.5 == isb('c0d00000')
50 x('.4p-124') == isb('00800000')
51 x('.2p-124') == isb('00400000')
52
53 # Using converter at http://babbage.cs.qc.edu/IEEE-754/Decimal.html
54 # plus Emacs 'calc' to convert decimal to hexadecimal
55 x('.7b74bc6a7ef9db23p8') => isb('42f6e979')             # 123.456
56 x('.7b74bc6a7ef9db23p8') => idb('405edd2f1a9fbe77')
57 x('.817427d2d4642004p-12') => isb('39017428')           # .0001234567
58 x('.817427d2d4642004p-12') => idb('3f202e84fa5a8c84')
59 x('.446c3b15f9926688p168') => isb('7f800000')           # 1e50; overflow
60 x('.446c3b15f9926688p168') => idb('4a511b0ec57e649a')
61
62 # From multiple editions of the z/Architecture Principles of Operation
63 # manual.
64               1.0 == zs('41100000') == isb('3f800000')
65               0.5 == zs('40800000') == isb('3f000000')
66        x('.4p-4') == zs('3f400000') == isb('3c800000')
67                 0 == zs('00000000') == isb('00000000')
68                      zs('80000000') == isb('80000000')
69               -15 == zs('c1f00000') == isb('c1700000')
70 # x('.ffffffp252') == zs('7fffffff')
71       x('.3b4p8') == zs('423b4000')
72      x('.1p-256') == zs('00100000')
73      x('.4p-124') == zs('21400000') == isb('00800000')
74      x('.8p-148') == zs('1b800000') == isb('00000001')
75 # x('.ffffffp128') == zs('60ffffff') == isb('7f7fffff')
76      x('.1p-256') == zs('00100000')
77      x('.1p-256') => isb('00000000')              # Underflow to zero.
78  x('.ffffffp248') == zs('7effffff')
79  x('.ffffffp248') => isb('7f800000')              # Overflow to +Infinity.
80
81             x('.4p-1020') => zl('0000000000000000')     # Underflow to zero.
82             x('.4p-1020') == idb('0010000000000000')
83             x('.4p-1072') => zl('0000000000000000')     # Underflow to zero.
84             x('.4p-1072') => idb('0000000000000001')
85 x('.fffffffffffff8p1024') => zl('7fffffffffffffff')     # Overflow to maxval.
86 x('.fffffffffffff8p1024') => idb('7fefffffffffffff')
87             x('.1p-256') == zl('0010000000000000') == idb('2fb0000000000000')
88  x('.ffffffffffffffp248') == zl('7effffffffffffff')
89  x('.ffffffffffffffp248') => idb('4f70000000000000')    # Loses precision.
90 ])
91 AT_CHECK(
92   [sed 's/#.*//
93 s/^[    ]*//
94 s/[     ]*$//
95 /^$/d
96 s/^\(..*\)$/DEBUG FLOAT FORMAT \1./' < float-format.txt > float-format.sps])
97 AT_CHECK([pspp --testing-mode -O format=csv float-format.sps])
98 AT_CLEANUP