dnl PSPP - a program for statistical analysis. dnl Copyright (C) 2017 Free Software Foundation, Inc. dnl dnl This program is free software: you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation, either version 3 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program. If not, see . dnl AT_BANNER([floating point formats]) AT_SETUP([floating point format conversions]) AT_DATA([float-format.txt], [dnl # Each of the tests below checks that conversion between # floating-point formats works correctly. Comparisons that use == # require that conversion from any format on the line to any other # format on the line work losslessly. Comparisons that use => only # check that conversions work losslessly in the given direction. # Key to format names: # isl: IEEE single-precision, little endian # isb: IEEE single-precision, big endian # idl: IEEE double-precision, little endian # idb: IEEE double-precision, big endian # vf: VAX F # vd: VAX D # vg: VAX G # zs: Z architecture short # zl: Z architecture long # x: hexadecimal digits # IEEE special values. 0 == isb('00000000') x('Infinity') == isb('7f800000') x('-Infinity') == isb('ff800000') x('NaN:') => isb('7f800001') # NaN requires nonzero fraction. x('NaN:e000000000000000') == isb('7ff00000') == idb('7ffe000000000000') x('NaN:5a5a5e0000000000') == isb('7fad2d2f') == idb('7ff5a5a5e0000000') x('NaN:975612abcdef4000') == idb('7ff975612abcdef4') x('-NaN:e000000000000000') == isb('fff00000') == idb('fffe000000000000') x('-NaN:5a5a5e0000000000') == isb('ffad2d2f') == idb('fff5a5a5e0000000') x('-NaN:975612abcdef4000') == idb('fff975612abcdef4') # PSPP special values. x('Missing') == isb('ff7fffff') == idb('ffefffffffffffff') == isl('ffff7fff') == idl('ffffffffffffefff') == vf('ffffffff') == vd('ffffffffffffffff') == vg('ffffffffffffffff') == zs('ffffffff') == zl('ffffffffffffffff') x('Lowest') == isb('ff7ffffe') == idb('ffeffffffffffffe') == isl('feff7fff') == idl('feffffffffffefff') == vf('fffffeff') == vd('fffffeffffffffff') == vg('fffffeffffffffff') == zs('fffffffe') == zl('fffffffffffffffe') x('Highest') == isb('7f7fffff') == idb('7fefffffffffffff') == isl('ffff7f7f') == idl('ffffffffffffef7f') == vf('ff7fffff') == vd('ffffffffff7fffff') == vg('ffffffffff7fffff') == zs('7fffffff') == zl('7fffffffffffffff') # From Wikipedia. 0.15625 == isb('3e200000') -118.625 == isb('c2ed4000') # http://www.psc.edu/general/software/packages/ieee/ieee.html x('NaN:0400000000000000') == isb('7f820000') x('-NaN:2225540000000000') == isb('ff9112aa') 2 == isb('40000000') 6.5 == isb('40d00000') -6.5 == isb('c0d00000') x('.4p-124') == isb('00800000') x('.2p-124') == isb('00400000') # Using converter at http://babbage.cs.qc.edu/IEEE-754/Decimal.html # plus Emacs 'calc' to convert decimal to hexadecimal x('.7b74bc6a7ef9db23p8') => isb('42f6e979') # 123.456 x('.7b74bc6a7ef9db23p8') => idb('405edd2f1a9fbe77') x('.817427d2d4642004p-12') => isb('39017428') # .0001234567 x('.817427d2d4642004p-12') => idb('3f202e84fa5a8c84') x('.446c3b15f9926688p168') => isb('7f800000') # 1e50; overflow x('.446c3b15f9926688p168') => idb('4a511b0ec57e649a') # From multiple editions of the z/Architecture Principles of Operation # manual. 1.0 == zs('41100000') == isb('3f800000') 0.5 == zs('40800000') == isb('3f000000') x('.4p-4') == zs('3f400000') == isb('3c800000') 0 == zs('00000000') == isb('00000000') zs('80000000') == isb('80000000') -15 == zs('c1f00000') == isb('c1700000') # x('.ffffffp252') == zs('7fffffff') x('.3b4p8') == zs('423b4000') x('.1p-256') == zs('00100000') x('.4p-124') == zs('21400000') == isb('00800000') x('.8p-148') == zs('1b800000') == isb('00000001') # x('.ffffffp128') == zs('60ffffff') == isb('7f7fffff') x('.1p-256') == zs('00100000') x('.1p-256') => isb('00000000') # Underflow to zero. x('.ffffffp248') == zs('7effffff') x('.ffffffp248') => isb('7f800000') # Overflow to +Infinity. x('.4p-1020') => zl('0000000000000000') # Underflow to zero. x('.4p-1020') == idb('0010000000000000') x('.4p-1072') => zl('0000000000000000') # Underflow to zero. x('.4p-1072') => idb('0000000000000001') x('.fffffffffffff8p1024') => zl('7fffffffffffffff') # Overflow to maxval. x('.fffffffffffff8p1024') => idb('7fefffffffffffff') x('.1p-256') == zl('0010000000000000') == idb('2fb0000000000000') x('.ffffffffffffffp248') == zl('7effffffffffffff') x('.ffffffffffffffp248') => idb('4f70000000000000') # Loses precision. ]) AT_CHECK( [sed 's/#.*// s/^[ ]*// s/[ ]*$// /^$/d s/^\(..*\)$/DEBUG FLOAT FORMAT \1./' < float-format.txt > float-format.sps]) AT_CHECK([pspp --testing-mode -O format=csv float-format.sps]) AT_CLEANUP