From: Matthias Heil Date: Mon, 4 Aug 2003 13:45:59 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=959986eec0ebb58eaaca065417cf2a373cfba49e;p=libfirm *** empty log message *** [r1633] --- diff --git a/ir/tv/IeeeCC754/BasicOp/testsets/add b/ir/tv/IeeeCC754/BasicOp/testsets/add new file mode 100644 index 000000000..10d75e712 --- /dev/null +++ b/ir/tv/IeeeCC754/BasicOp/testsets/add @@ -0,0 +1,943 @@ +!! This file contains precision and range independent test vectors for +!! the operation addition/subtraction (+). The first character in each +!! test vector refers to the origin of the test vector +!! +!! 2: Jerome Coonen Version <2> +!! 3: Jerome Coonen Version <3> +!! @Phdthesis{ +!! author = {Coonen, J.T.}, +!! title = {Contributions to a proposed standard for binary +!! floating-point arithmetic}, +!! school = {University of California, Berkeley}, +!! year = {1984}} +!! +!! H: precision independent encoding of UCB/ough test vector +!! @Unpublished{ +!! author = {David G. Hough and others}, +!! title = {{UCBTEST}, a suite of programs for testing certain +!! difficult cases of {IEEE} 754 floating-point arithmetic}, +!! year = {1988}, +!! note = {Restricted public domain software from +!! http://netlib.bell-labs.com/netlib/fp/index.html}} +!! +!! A: Verdonk-Cuyt-Verschaeren (University of ntwerp) +!! @Article{ +!! author = {Verdonk, B. and Cuyt, A. and Verschaeren, D.}, +!! title = {A precision- and range-independent tool for testing +!! floating-point arithmetic {I}: basic operations, +!! square root and remainder}, +!! journal = {ACM TOMS}, +!! volume = {27}, +!! number = {1}, +!! pages = {92-118}, +!! year = {2001}} +!! note = {Under revision}} +!! +!! This file is part of the tool IeeeCC754 or IEEE 754 Compliance Checker. +!! It is a precision and range independent tool to test whether +!! an implementation of floating-point arithmetic (in hardware or +!! software) is compliant with the principles of the IEEE 754-854 +!! floating-point standards. You can find out more about the testing +!! tool IeeeCC754 and the syntax and semantics of the test vectors +!! at +!! http://win-www.uia.ac.be/u/cant/ieeecc754.html +!! +!! Last updated: +!! $Date$ +!! +!! Contact: +!! Brigitte.Verdonk@ua.ac.be +!! Department of Mathematics and Computer Science +!! University of Antwerp (UIA) +!! Universiteitsplein 1 +!! B2610 Antwerp, BELGIUM +!!!! first some easy cases +2+ ALL 1 1 OK 2 +!! c0a00000 00000000 c0a00000 00000000 c0b00000 00000000 +H+ ALL -1 -1 OK -2 +2+ ALL 1 2 OK 3 +!! c0a00000 00000000 c0b00000 00000000 c0b80000 00000000 +H+ ALL -1 -2 OK -3 +2+ ALL 2 2 OK 4 +2+ ALL 1 7 OK 8 +A+ ALL -1 -7 OK -8 +2+ ALL 5 -1 OK 4 +A+ ALL -5 1 OK -4 +2+ ALL 2 -5 OK -3 +A+ ALL -2 5 OK 3 +!! 40a00000 00000000 c0b00000 00000000 c0a00000 00000000 +H+ ALL 2 -4 OK -2 +!! 40b00000 00000000 c0a00000 00000000 40a00000 00000000 +H+ ALL 4 -2 OK 2 +!! c0a00000 00000000 40b00000 00000000 40a00000 00000000 +!! c0b00000 00000000 40a00000 00000000 c0a00000 00000000 + +!! Special representations + +! Zero vs Zero -- watch signs and rounding modes. +2+ =0> 0 -0 OK 0 +2+ < 0 -0 OK -0 +2+ ALL 0 0 OK 0 +2+ ALL -0 -0 OK -0 +!! Zero vs denormalized +2+ ALL 0 Td1 OK Td1 +2+ ALL -0 Td1 OK Td1 +2+ ALL 0 -Td1 OK -Td1 +2+ ALL -0 -Td1 OK -Td1 +2+ ALL 0i3 0 OK 0i3 +2+ ALL 0i3 -0 OK 0i3 +2+ ALL -0i3 0 OK -0i3 +2+ ALL -0i3 -0 OK -0i3 +!! Zero vs normal -- watch that sign of 0 is meaningless +2+ ALL -0 -T OK -T +2+ ALL T 0 OK T +2+ ALL 0 -T OK -T +2+ ALL 0 Hm1 OK Hm1 +2+ ALL -0 Hm1 OK Hm1 +2+ ALL -Hm1 0 OK -Hm1 +2+ ALL -Hm1 -0 OK -Hm1 +2+ ALL 1 -0 OK 1 +2+ ALL -1 -0 OK -1 +2+ ALL 0 1 OK 1 +2+ ALL 5 -0 OK 5 +2+ ALL 5 +0 OK 5 +! Infinity vs 0. +2+ ALL H 0 OK H +2+ ALL H -0 OK H +2+ ALL -H 0 OK -H +2+ ALL -H -0 OK -H +!! NaN versus 0 +2+ ALL Q 0 OK Q +2+ ALL Q -0 OK Q +! 2+ ALL S 0 i Q +! 2+ ALL S -0 i Q +! 2+ ALL 0 S i Q +! 2+ ALL -0 S i Q +! Infinity vs Infinity. +2+ ALL H H OK H ok - affine sum +2+ ALL -H -H OK -H +2+ ALL -H H i Q different signs +! Infinity vs denormalized. +2+ ALL H Td1 OK H +2+ ALL -H Td1 OK -H +2+ ALL H -Td1 OK H +2+ ALL -H -Td1 OK -H +2+ ALL 0i3 H OK H +2+ ALL 0i3 -H OK -H +2+ ALL -0i3 H OK H +2+ ALL -0i3 -H OK -H +! Infinity vs huge. +2+ ALL H Hm1 OK H +2+ ALL H -Hm1 OK H +2+ ALL -H Hm1 OK -H +2+ ALL -H -Hm1 OK -H +!! Infinity vs NaN +2+ ALL Q H OK Q +2+ ALL Q -H OK Q +! 2+ ALL S H i Q +! 2+ ALL S -H i Q +! 2+ ALL H S i Q +! 2+ ALL -H S i Q +!! NaN versus NaN +2+ ALL Q Q OK Q +! 2+ ALL Q S i Q +! 2+ ALL S Q i Q +! 2+ ALL S S i Q +!! NaN versus denormal +2+ ALL Td1 Q OK Q +2+ ALL -Td1 Q OK Q +2+ ALL Q 0i1 OK Q +2+ ALL Q -0i1 OK Q +! 2+ ALL Td1 S i Q +! 2+ ALL -Td1 S i Q +! 2+ ALL S Td1 i Q +! 2+ ALL S -Td1 i Q +! 2+ ALL S 0i1 i Q +! 2+ ALL S -0i1 i Q +! 2+ ALL 0i1 S i Q +! 2+ ALL -0i1 S i Q +!! NaN versus normal +2+ ALL Q 1 OK Q +2+ ALL Q -1 OK Q +2+ ALL Q Hd1 OK Q +2+ ALL Q -Hd1 OK Q +! 2+ ALL S 1 i Q +! 2+ ALL S -1 i Q +! 2+ ALL 1 S i Q +! 2+ ALL -1 S i Q +! 2+ ALL S Hd1 i Q +! 2+ ALL S -Hd1 i Q +! 2+ ALL Hd1 S i Q +! 2+ ALL -Hd1 S i Q + +!! Exceptions + +!! invalid, only for operations involving SNaNs, see above +!! inexact, overflow +!! leading bits => carry +2+ => Hm1 Hm1 xo H +2+ 0< Hm1 Hm1 xo Hd1 +2+ =< -Hm1 -Hm1 xo -H +2+ 0> -Hm1 -Hm1 xo -Hd1 +2+ => Hd2 Hd2 xo H +2+ 0< Hd2 Hd2 xo Hd1 +2+ =< -Hd2 -Hd2 xo -H +2+ 0> -Hd2 -Hd2 xo -Hd1 +2+ => Hd2 Hd1 xo H +2+ 0< Hd2 Hd1 xo Hd1 +2+ =< -Hd2 -Hd1 xo -H +2+ 0> -Hd2 -Hd1 xo -Hd1 +2+ => Hm1i1 Hm1 xo H +2+ 0< Hm1i1 Hm1 xo Hd1 +2+ =< -Hm1i1 -Hm1 xo -H +2+ 0> -Hm1i1 -Hm1 xo -Hd1 +A+ => Hd1 Hmtp1 xo H +A+ 0< Hd1 Hmtp1 xo Hd1 +A+ =< -Hd1 -Hmtp1 xo -H +A+ 0> -Hd1 -Hmtp1 xo -Hd1 +!! Result = Max. normal, round bit = 0, sticky bit = 0(...1...) +2+ =0< Hd1 1 x Hd1 +2+ > Hd1 1 xo H +!! 3ff00000 00000000 7fefffff ffffffff 7fefffff ffffffff +2+ =0> -Hd1 -1 x -Hd1 +2+ < -Hd1 -1 xo -H +!! bff00000 00000000 ffefffff ffffffff ffefffff ffffffff +!! bff00000 00000000 ffefffff ffffffff fff00000 00000000 +2+ =0< 0i1 Hd1 x Hd1 +2+ > 0i1 Hd1 xo H +2+ =0> -0i1 -Hd1 x -Hd1 +2+ < -0i1 -Hd1 xo -H +!! Result = Max. normal, round bit = 0, sticky bit = 1(0000...) +A+ =0< Hd1 Hmtm2 x Hd1 +A+ > Hd1 Hmtm2 xo H +A+ =0> -Hd1 -Hmtm2 x -Hd1 +A+ < -Hd1 -Hmtm2 xo -H +!! Result = Max. normal, round bit = 0, sticky bit = 1(...1...) +A+ =0< Hd1 Hmtm2i1 x Hd1 +A+ > Hd1 Hmtm2i1 xo H +A+ =0> -Hd1 -Hmtm2i1 x -Hd1 +A+ < -Hd1 -Hmtm2i1 xo -H +!! Result = Max. normal, round bit = 1, sticky bit = 0 => round to even +2+ => Hm1d1 Hm1 xo H +2+ 0< Hm1d1 Hm1 x Hd1 +2+ =< -Hm1d1 -Hm1 xo -H +2+ 0> -Hm1d1 -Hm1 x -Hd1 +!! Result = Max. normal, round bit = 1, sticky bit = 1(0000...) +A+ => Hd1 3pB0mtm1 xo H +A+ 0< Hd1 3pB0mtm1 x Hd1 +A+ =< -Hd1 -3pB0mtm1 xo -H +A+ 0> -Hd1 -3pB0mtm1 x -Hd1 +!! Result = Max. normal, round bit = 1, sticky bit = 0(...1...) +A+ => Hd1 Hmtm1i1 xo H +A+ 0< Hd1 Hmtm1i1 x Hd1 +A+ =< -Hd1 -Hmtm1i1 xo -H +A+ 0> -Hd1 -Hmtm1i1 x -Hd1 +!! Result = Max. normal, round bit = 1, sticky bit = 1(...1...) +A+ => Hd1 3pB0mtm1i1 xo H +A+ 0< Hd1 3pB0mtm1i1 x Hd1 +A+ =< -Hd1 -3pB0mtm1i1 xo -H +A+ 0> -Hd1 -3pB0mtm1i1 x -Hd1 +!! Exp. Z = U - 1, Result <= Max. normal, no overflow +2+ =0< Hm1 1 x Hm1 +2+ > Hm1 1 x Hm1i1 +2+ =0> -Hm1 -1 x -Hm1 +2+ < -Hm1 -1 x -Hm1i1 +2+ =0< Hm1d1 1 x Hm1d1 +2+ > Hm1d1 1 x Hm1 +2+ =0< Hd2 1 x Hd2 +2+ > Hd2 1 x Hd1 +2+ =0> -Hd2 -1 x -Hd2 +2+ < -Hd2 -1 x -Hd1 +!! bff00000 00000000 ffeffffff fffffffe ffefffff fffffffe +!! bff00000 00000000 ffeffffff fffffffe ffefffff ffffffff +2+ =0< 0i1 Hm1 x Hm1 +2+ > 0i1 Hm1 x Hm1i1 +2+ =0> -0i1 -Hm1 x -Hm1 +2+ < -0i1 -Hm1 x -Hm1i1 +2+ =0< 0i1 Hm1d1 x Hm1d1 +2+ > 0i1 Hm1d1 x Hm1 +2+ =0> -0i1 -Hm1d1 x -Hm1d1 +2+ < -0i1 -Hm1d1 x -Hm1 +2+ =0< 0i1 Hd2 x Hd2 +2+ > 0i1 Hd2 x Hd1 +2+ =0> -0i1 -Hd2 x -Hd2 +2+ < -0i1 -Hd2 x -Hd1 +!! Result <= Max. normal, no overflow +A+ ALL Hm1 Hmt OK Hm1i1 +A+ ALL -Hm1 -Hmt OK -Hm1i1 +2+ ALL Hm1d2 Hm1d2 OK Hd2 +2+ ALL -Hm1d2 -Hm1d2 OK -Hd2 +! Double an innocent number. +2+ ALL 3 3 OK 6 +2+ ALL T T OK Tp1 +2+ ALL Hm2 Hm2 OK Hm1 +!! underflow cannot occur +! Double a tiny number +2+ ALL Td1 Td1 OK Tp1d2 +2+ ALL -Td1 -Td1 OK -Tp1d2 +2+ ALL 0i4 0i4 OK 0i8 +2+ ALL -0i4 -0i4 OK -0i8 +2+ ALL 0i1 0i1 OK 0i2 +2+ ALL -0i1 -0i1 OK -0i2 +!! inexact, see rounding below + +!! Exact rounding + +!! round bit = 0, sticky bit = 0(...1...) => inexact, round down +!! normals +A+ =0< 1i1 8 x 9 +A+ > 1i1 8 x 9i1 +A+ =0> -1i1 -8 x -9 +A+ < -1i1 -8 x -9i1 +A+ =0< 1ptp2 1 x 1ptp2 +A+ > 1ptp2 1 x 1ptp2i1 +A+ =0> -1ptp2 -1 x -1ptp2 +A+ < -1ptp2 -1 x -1ptp2i1 +!! bff00000 00000000 ffe00000 00000000 ffe00000 00000000 +!! bff00000 00000000 ffe00000 00000000 ffe00000 00000001 +! Medium vs denormal. +A+ =0< Tp3 0i1 x Tp3 +A+ > Tp3 0i1 x Tp3i1 +A+ =0> -Tp3 -0i1 x -Tp3 +A+ < -Tp3 -0i1 x -Tp3i1 +2+ =0< 0i1 1 x 1 +2+ > 0i1 1 x 1i1 +2+ =0> -0i1 -1 x -1 +2+ < -0i1 -1 x -1i1 +!! bff00000 0000000 80000000 00000001 bff00000 00000000 +!! bff00000 0000000 80000000 00000001 bff00000 00000001 +2+ =0< 0i1 1d1 x 1d1 +2+ > 0i1 1d1 x 1 +2+ =0> -0i1 -1d1 x -1d1 +2+ < -0i1 -1d1 x -1 +2+ =0< 0i1 2d1 x 2d1 +2+ > 0i1 2d1 x 2 +2+ =0> -0i1 -2d1 x -2d1 +2+ < -0i1 -2d1 x -2 +2+ =0< 0i1 2d2 x 2d2 +2+ > 0i1 2d2 x 2d1 +2+ =0> -0i1 -2d2 x -2d2 +2+ < -0i1 -2d2 x -2d1 +!! after carry propagation +!! 3fefffff ffffffff 3cb00800 00000000 3ff00000 00000000 +H+ =0< 8ptd1 11 x 8pt +!! 3fefffff ffffffff 3cb00800 00000000 3ff00000 00000001 +H+ > 8ptd1 11 x 8pti1 +!! bfefffff ffffffff bcb00800 00000000 bff00000 00000000 +H+ =0> -8ptd1 -11 x -8pt +!! bfefffff ffffffff bcb00800 00000000 bff00000 00000001 +H+ < -8ptd1 -11 x -8pti1 +!! subtract +!! normal operands +A+ > 7pt -7 x 7pt +A+ =0< 7pt -7 x 7ptd1 +A+ < 7 -7pt x -7pt +A+ =0> 7 -7pt x -7ptd1 +!! denormal operand +A+ > Tp4 -0i7 x Tp4 +A+ =0< Tp4 -0i7 x Tp4d1 +A+ < -Tp4 0i7 x -Tp4 +A+ =0> -Tp4 0i7 x -Tp4d1 +!! round bit = 0, sticky bit = 1(0000...) => inexact, round down +!! normal operands +A+ =0< 1i1 4 x 5 +A+ > 1i1 4 x 5i1 +A+ =0> -1i1 -4 x -5 +A+ < -1i1 -4 x -5i1 +A+ =0< 1ptp1 1 x 1ptp1 +A+ > 1ptp1 1 x 1ptp1i1 +A+ =0> -1ptp1 -1 x -1ptp1 +A+ < -1ptp1 -1 x -1ptp1i1 +!! after carry propagation +A+ =0< 10 8ptd1 x 8pt +A+ > 10 8ptd1 x 8pti1 +A+ =0> -10 -8ptd1 x -8pt +A+ < -10 -8ptd1 x -8pti1 +!! subtract +!! normal operands +A+ =0< 4 -3mt x 4d1 +A+ > 4 -3mt x 4 +A+ =0> 3 -4pt x -4ptd1 +A+ < 3 -4pt x -4pt +A+ =0> -4 +3mt x -4d1 +A+ < -4 +3mt x -4 +A+ =0< -3 4pt x 4ptd1 +A+ > -3 4pt x 4pt +!! denormal operand +A+ =0< Tp3 -0i3 x Tp3d1 +A+ > Tp3 -0i3 x Tp3 +A+ =0> -Tp3 0i3 x -Tp3d1 +A+ < -Tp3 0i3 x -Tp3 +!! round bit = 0, sticky bit = 1 => inexact, round down +A+ =0< 1i3 8 x 9 +A+ > 1i3 8 x 9i1 +A+ =0> -1i3 -8 x -9 +A+ < -1i3 -8 x -9i1 +2+ > 4d1 1u1d1 x 4 +2+ 0=< 4d1 1u1d1 x 4d1 +2+ < -4d1 -1u1d1 x -4 +2+ 0=> -4d1 -1u1d1 x -4d1 +!! denormal +A+ =0< Tp3 0i3 x Tp3 +A+ > Tp3 0i3 x Tp3i1 +A+ =0> -0i3 -Tp3 x -Tp3 +A+ < -0i3 -Tp3 x -Tp3i1 +!! after carry propagation +A+ =0< 14 8ptd1 x 8pt +A+ > 14 8ptd1 x 8pti1 +A+ =0> -14 -8ptd1 x -8pt +A+ < -14 -8ptd1 x -8pti1 +!! subtract +!! normal operands +A+ =0< 8 -5mt x 8d1 +A+ > 8 -5mt x 8 +A+ =0> 5 -8pt x -8ptd1 +A+ < 5 -8pt x -8pt +A+ =0> -8 +5mt x -8d1 +A+ < -8 +5mt x -8 +A+ =0< -5 8pt x 8ptd1 +A+ > -5 8pt x 8pt +!! denormal operand +A+ =0< Tp4 -0i5 x Tp4d1 +A+ > Tp4 -0i5 x Tp4 +A+ =0> -Tp4 0i5 x -Tp4d1 +A+ < -Tp4 0i5 x -Tp4 +!! round bit = 1, sticky bit = 0 +!! half-way cases, round to even +!! even result +!! normal operands +A+ =0< 1u1 2 x 2 +A+ > 1u1 2 x 2i1 +A+ =0> -1u1 -2 x -2 +A+ < -1u1 -2 x -2i1 +!! denormal +A+ =0< 0i1 Tp1 x Tp1 +A+ > 0i1 Tp1 x Tp1i1 +A+ =0> -0i1 -Tp1 x -Tp1 +A+ < -0i1 -Tp1 x -Tp1i1 +!! after carry propagation +2+ =0< 1i1 1 x 2 +2+ > 1i1 1 x 2i1 +2+ =0> -1i1 -1 x -2 +2+ < -1i1 -1 x -2i1 +!! bff00000 00000000 bff00000 00000001 c0000000 00000000 +!! bff00000 00000000 bff00000 00000001 c0000000 00000001 +2+ =0< Hm2i1 Hm2 x Hm1 +2+ > Hm2i1 Hm2 x Hm1i1 +2+ =0< 2 2i1 x 4 +2+ > 2 2i1 x 4i1 +2+ =0< Hm1d2 Hm1d1 x Hd2 +2+ > Hm1d2 Hm1d1 x Hd1 +2+ =0> -Hm2i1 -Hm2 x -Hm1 +2+ < -Hm2i1 -Hm2 x -Hm1i1 +2+ =0> -2 -2i1 x -4 +2+ < -2 -2i1 x -4i1 +2+ =0> -Hm1d2 -Hm1d1 x -Hd2 +2+ < -Hm1d2 -Hm1d1 x -Hd1 +!! subtract +!! normal operands +A+ =0< 1i1 -1u1m1 x 1 +A+ > 1i1 -1u1m1 x 1i1 +A+ =0> 1u1m1 -1i1 x -1 +A+ < 1u1m1 -1i1 x -1i1 +!! denormal +A+ =0< Tp1i1 -0i1 x Tp1 +A+ > Tp1i1 -0i1 x Tp1i1 +A+ =0> -Tp1i1 0i1 x -Tp1 +A+ < -Tp1i1 0i1 x -Tp1i1 +!! odd result +!! normal operands +A+ => 1u1 4d1 x 4 +A+ 0< 1u1 4d1 x 4d1 +A+ =< -1u1 -4d1 x -4 +A+ 0> -1u1 -4d1 x -4d1 +!! denormal +A+ => 0i1 Tp1i1 x Tp1i2 +A+ 0< 0i1 Tp1i1 x Tp1i1 +A+ =< -0i1 -Tp1i1 x -Tp1i2 +A+ 0> -0i1 -Tp1i1 x -Tp1i1 +!! after carry propagation +2+ => 1 1i3 x 2i2 +2+ 0< 1 1i3 x 2i1 +2+ => 2i1 2i2 x 4i2 +2+ 0< 2i1 2i2 x 4i1 +2+ =< -1 -1i3 x -2i2 +2+ 0> -1 -1i3 x -2i1 +2+ =< -2i1 -2i2 x -4i2 +2+ 0> -2i1 -2i2 x -4i1 +A+ => 1u1 2i1 x 2i2 +A+ 0< 1u1 2i1 x 2i1 +A+ =< -1u1 -2i1 x -2i2 +A+ 0> -1u1 -2i1 x -2i1 +!! subtract +!! normal operands +A+ => 2i2 -1u1 x 2i2 +A+ 0< 2i2 -1u1 x 2i1 +A+ =< 1u1 -2i2 x -2i2 +A+ 0> 1u1 -2i2 x -2i1 +!! denormal +A+ => Tp2i2 -0i1 x Tp2i2 +A+ 0< Tp2i2 -0i1 x Tp2i1 +A+ =< -Tp2i2 0i1 x -Tp2i2 +A+ 0> -Tp2i2 0i1 x -Tp2i1 +!! round bit = 1, sticky bit = 1(0000...) => inexact, round up +!! normals +A+ => 1i3 4 x 5i1 +A+ 0< 4 1i3 x 5 +A+ =< -1i3 -4 x -5i1 +A+ 0> -1i3 -4 x -5 +A+ => 3 3pt x 3pti1 +A+ 0< 3 3pt x 3pt +A+ =< -3 -3pt x -3pti1 +A+ 0> -3 -3pt x -3pt +!! denormal +A+ => 0i3 Tp2 x Tp2i1 +A+ 0< 0i3 Tp2 x Tp2 +A+ =< -0i3 -Tp2 x -Tp2i1 +A+ 0> -0i3 -Tp2 x -Tp2 +!! after carry propagation +A+ => 2d1 5mt x 2i1 +A+ 0< 2d1 5mt x 2 +A+ =< -2d1 -5mt x -2i1 +A+ 0> -2d1 -5mt x -2 +!! subtract +!! normals +A+ => 4pt -1 x 4pt +A+ 0< 4pt -1 x 4ptd1 +A+ =< 1 -4pt x -4pt +A+ 0> 1 -4pt x -4ptd1 +!! denormal +A+ => Tp3 -0i1 x Tp3 +A+ 0< Tp3 -0i1 x Tp3d1 +A+ =< -Tp3 0i1 x -Tp3 +A+ 0> -Tp3 0i1 x -Tp3d1 +!! round bit = 1, sticky bit = 0(...1...) => inexact, round up +!! normals +A+ => 1i5 8 x 9i1 +A+ 0< 1i5 8 x 9 +A+ =< -1i5 -8 x -9i1 +A+ 0> -1i5 -8 x -9 +A+ => 5 4pt x 4pti1 +A+ 0< 5 4pt x 4pt +A+ =< -5 -4pt x -4pti1 +A+ 0> -5 -4pt x -4pt +!! denormal +A+ => 0i5 Tp3 x Tp3i1 +A+ 0< 0i5 Tp3 x Tp3 +A+ =< -0i5 -Tp3 x -Tp3i1 +A+ 0> -0i5 -Tp3 x -Tp3 +!! after carry propagation +A+ => 2d1 4mti1 x 2i1 +A+ 0< 2d1 4mti1 x 2 +A+ =< -2d1 -4mti1 x -2i1 +A+ 0> -2d1 -4mti1 x -2 +!! subtract +!! normal operands +A+ => 6ptp1 -3 x 6ptp1 +A+ 0< 6ptp1 -3 x 6ptp1d1 +A+ =< 3 -6ptp1 x -6ptp1 +A+ 0> 3 -6ptp1 x -6ptp1d1 +!! denormal operand +A+ => Tp4 -0i3 x Tp4 +A+ 0< Tp4 -0i3 x Tp4d1 +A+ =< -Tp4 0i3 x -Tp4 +A+ 0> -Tp4 0i3 x -Tp4d1 +!! round bit = 1, sticky bit = 1(...1...) => inexact, round up +!! normal +A+ >= 1i7 8 x 9i1 +A+ 0< 1i7 8 x 9 +A+ =< -1i7 -8 x -9i1 +A+ 0> -1i7 -8 x -9 +A+ => 7 7pt x 7pti1 +A+ 0< 7 7pt x 7pt +A+ =< -7 -7pt x -7pti1 +A+ 0> -7 -7pt x -7pt +!! denormal +A+ => 0i7 Tp3 x Tp3i1 +A+ 0< 0i7 Tp3 x Tp3 +A+ =< -0i7 -Tp3 x -Tp3i1 +A+ 0> -0i7 -Tp3 x -Tp3 +!! after carry propagation +A+ => 2d1 5mti1 x 2i1 +A+ 0< 2d1 5mti1 x 2 +A+ =< -2d1 -5mti1 x -2i1 +A+ 0> -2d1 -5mti1 x -2 +!! subtract +! Magnitude subtract when an operand is in the sticky bit. +! The interesting cases will arise when directed rounding +! forces a nonzero cancellation. +! Huge and medium. +2+ => Hm1 -1 x Hm1 +2+ 0< Hm1 -1 x Hm1d1 +!! bff00000 00000000 7fe00000 000000000 7fe00000 00000000 +!! bff00000 00000000 7fe00000 000000000 7fdfffff ffffffff +2+ =< -Hm1 1 x -Hm1 +2+ 0> -Hm1 1 x -Hm1d1 +!! 3ff00000 00000000 ffe00000 00000000 ffe00000 00000000 +!! 3ff00000 00000000 ffe00000 00000000 ffdfffff ffffffff +2+ => Hm1d1 -1 x Hm1d1 +2+ 0< Hm1d1 -1 x Hm1d2 +!! bff00000 00000000 7fdfffff ffffffff 7fdfffff ffffffff +!! bff00000 00000000 7fdfffff ffffffff 7fdfffff fffffffe +2+ =< -Hm1d1 1 x -Hm1d1 +2+ 0> -Hm1d1 1 x -Hm1d2 +!! 3ff00000 00000000 ffdfffff ffffffff ffdfffff ffffffff +!! 3ff00000 00000000 ffdfffff ffffffff ffdfffff fffffffe +2+ => Hd1 -1 x Hd1 +2+ 0< Hd1 -1 x Hd2 +!! bff00000 00000000 7fefffff ffffffff 7fefffff ffffffff +!! bff00000 00000000 7fefffff ffffffff 7fefffff fffffffe +2+ =< -Hd1 1 x -Hd1 +2+ 0> -Hd1 1 x -Hd2 +!! 3ff00000 00000000 ffefffff ffffffff ffefffff ffffffff +!! 3ff00000 00000000 ffefffff ffffffff ffefffff fffffffe +2+ => Hd2 -1 x Hd2 +2+ 0< Hd2 -1 x Hd3 +!! bff00000 00000000 7fefffff fffffffe 7fefffff fffffffe +!! bff00000 00000000 7fefffff fffffffe 7fefffff fffffffd +2+ =< -Hd2 1 x -Hd2 +2+ 0> -Hd2 1 x -Hd3 +!! 3ff00000 00000000 ffefffff fffffffe ffefffff fffffffe +!! 3ff00000 00000000 ffefffff fffffffe ffefffff fffffffd +! Huge and tiny. +2+ => Hd1 -0i1 x Hd1 +2+ 0< Hd1 -0i1 x Hd2 +2+ =< -Hd1 0i1 x -Hd1 +2+ 0> -Hd1 0i1 x -Hd2 +2+ => -0i3 Hm1 x Hm1 +2+ 0< -0i3 Hm1 x Hm1d1 +2+ =< 0i3 -Hm1 x -Hm1 +2+ 0> 0i3 -Hm1 x -Hm1d1 +! Medium and tiny. +2+ => 1d1 -0i1 x 1d1 +2+ 0< 1d1 -0i1 x 1d2 +2+ =< -2d1 0i1 x -2d1 +2+ 0> -2d1 0i1 x -2d2 +2+ => -0i3 3 x 3 +2+ 0< -0i3 3 x 3d1 +!! 40080000 00000000 80000000 00000003 40080000 00000000 +!! 40080000 00000000 80000000 00000003 4007ffff ffffffff +2+ =< 0i3 -5 x -5 +2+ 0> 0i3 -5 x -5d1 +!! c0140000 00000000 00000000 00000003 c0140000 00000000 +!! c0140000 00000000 00000000 00000003 c013ffff ffffffff + +!! cancellation + +! Cancellation to 0 -- to plus 0. +2+ =0> 2 -2 OK 0 +2+ =0> 5 -5 OK 0 +2+ =0> Hm1 -Hm1 OK 0 +2+ =0> -Hm1d2 Hm1d2 OK 0 +2+ =0> 1 -1 OK 0 +2+ =0> -3 3 OK 0 +2+ =0> T -T OK 0 +2+ =0> Td4 -Td4 OK 0 +2+ =0> -Td1 Td1 OK 0 no underflow +2+ =0> 0i1 -0i1 OK 0 +2+ =0> Hd1 -Hd1 OK 0 +! Cancellation to 0 -- to minus 0. +2+ < 2 -2 OK -0 +2+ < 5 -5 OK -0 +2+ < Hm1 -Hm1 OK -0 +2+ < -Hm1d2 Hm1d2 OK -0 +2+ < 1 -1 OK -0 +2+ < -3 3 OK -0 +2+ < T -T OK -0 +2+ < Td4 -Td4 OK -0 +2+ < -Td1 Td1 OK -0 no underflow +2+ < 0i1 -0i1 OK -0 +2+ < Hd1 -Hd1 OK -0 + +!! normalization + +! Cancel forcing normalization of LSB (no rounding errors). +2+ ALL 1i1 -1 OK 1u1 +!! bff00000 00000000 3ff000000 00000001 3cb00000 00000000 +2+ ALL Hm1i1 -Hm1 OK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hm3i3 OK Hm3i1 +2+ ALL Tp2i2 -Tp1i3 OK Tp1i1 +2+ ALL -2i2 1i3 OK -1i1 +2+ ALL -Hm2i2 Hm3i3 OK -Hm3i1 +2+ ALL -Tp2i2 Tp1i3 OK -Tp1i1 +!! low and high order bits +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 1i2 -1 OK 1mtp2 +A+ ALL -1i2 1 OK -1mtp2 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 1i4 -1 OK 1mtp3 +A+ ALL -1i4 1 OK -1mtp3 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 1i8 -1 OK 1mtp4 +A+ ALL -1i8 1 OK -1mtp4 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 17 -16 OK 1 +A+ ALL -17 +16 OK -1 +A+ ALL 16 -17 OK -1 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 9 -8 OK 1 +A+ ALL -9 8 OK -1 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 5 -4 OK 1 +A+ ALL -5 4 OK -1 +!! 41f00000 00004000 c1f00000 00000000 3f900000 00000000 +H+ ALL 3 -2 OK 1 +A+ ALL -3 2 OK -1 + +! Cases to test shifting in addition + +3+ =0< 2 1i1 x 3 +3+ > 2 1i1 x 3i1 +3+ =0< 10 1i1 x 11 +3+ > 10 1i1 x 11i1 +3+ =0< 19 1i1 x 20 +3+ > 19 1i1 x 20i1 +3+ =0< 32 1i1 x 33 +3+ > 32 1i1 x 33i1 +3+ =0< 65 1i1 x 66 +3+ > 65 1i1 x 66i1 +3+ =0< 133 1i1 x 134 +3+ > 133 1i1 x 134i1 +3+ =0< 260 1i1 x 261 +3+ > 260 1i1 x 261i1 +3+ =0< 533 1i1 x 534 +3+ > 533 1i1 x 534i1 +3+ =0< 1029 1i1 x 1030 +3+ > 1029 1i1 x 1030i1 +3+ =0< 2048 1i1 x 2049 +3+ > 2048 1i1 x 2049i1 +3+ =0< 4097 1i1 x 4098 +3+ > 4097 1i1 x 4098i1 +3+ =0< 8193 1i1 x 8194 +3+ > 8193 1i1 x 8194i1 +3+ =0< 16384 1i1 x 16385 +3+ > 16384 1i1 x 16385i1 +3+ =0< 32780 1i1 x 32781 +3+ > 32780 1i1 x 32781i1 +3+ =0< 65555 1i1 x 65556 +3+ > 65555 1i1 x 65556i1 +3+ =0< 131072 1i1 x 131073 +3+ > 131072 1i1 x 131073i1 +3+ =0< 263000 1i1 x 263001 +3+ > 263000 1i1 x 263001i1 +3+ =0< 525000 1i1 x 525001 +3+ > 525000 1i1 x 525001i1 +3+ =0< 1050000 1i1 x 1050001 +3+ > 1050000 1i1 x 1050001i1 +3+ =0< 2092700 1i1 x 2092701 +3+ > 2092700 1i1 x 2092701i1 +3+ =0< 4194305 1i1 x 4194306 +3+ > 4194305 1i1 x 4194306i1 +!! This is 2^23+1, the widest integer for IEEE single precision: +3+ =0< 8388609 1i1 x 8388610 +3+ > 8388609 1i1 x 8388610i1 +!! 3+ d=0< 16777300 1i1 x 16777301 +!! 3+ d> 16777300 1i1 x 16777301i1 +!! 3+ d=0< 33555000 1i1 x 33555001 +!! 3+ d> 33555000 1i1 x 33555001i1 +!! 3+ d=0< 67108880 1i1 x 67108881 +!! 3+ d> 67108880 1i1 x 67108881i1 +!! 3+ d=0< 134218000 1i1 x 134218001 +!! 3+ d> 134218000 1i1 x 134218001i1 +!! 3+ d=0< 268436000 1i1 x 268436001 +!! 3+ d> 268436000 1i1 x 268436001i1 +!! 3+ d=0< 0x41c0000000800000 1i1 x 0x41c0000001000000 +!! 3+ d> 0x41c0000000800000 1i1 x 0x41c0000001000001 +!! 3+ d=0< 0x41d0000000400000 1i1 x 0x41d0000000800000 +!! 3+ d> 0x41d0000000400000 1i1 x 0x41d0000000800001 +!! 3+ d=0< 0x41e0000000200000 1i1 x 0x41e0000000400000 +!! 3+ d> 0x41e0000000200000 1i1 x 0x41e0000000400001 +!! 3+ d=0< 0x41f0000000100000 1i1 x 0x41f0000000200000 +!! 3+ d> 0x41f0000000100000 1i1 x 0x41f0000000200001 +!! 3+ d=0< 0x4200000000080000 1i1 x 0x4200000000100000 +!! 3+ d> 0x4200000000080000 1i1 x 0x4200000000100001 +!! 3+ d=0< 0x4210000000040000 1i1 x 0x4210000000080000 +!! 3+ d> 0x4210000000040000 1i1 x 0x4210000000080001 +!! 3+ d=0< 0x4220000000020000 1i1 x 0x4220000000040000 +!! 3+ d> 0x4220000000020000 1i1 x 0x4220000000040001 +!! 3+ d=0< 0x4230000000010000 1i1 x 0x4230000000020000 +!! 3+ d> 0x4230000000010000 1i1 x 0x4230000000020001 +!! 3+ d=0< 0x4240000000008000 1i1 x 0x4240000000010000 +!! 3+ d> 0x4240000000008000 1i1 x 0x4240000000010001 +!! 3+ d=0< 0x4250000000004000 1i1 x 0x4250000000008000 +!! 3+ d> 0x4250000000004000 1i1 x 0x4250000000008001 +!! 3+ d=0< 0x4260000000002000 1i1 x 0x4260000000004000 +!! 3+ d> 0x4260000000002000 1i1 x 0x4260000000004001 +!! 3+ d=0< 0x4270000000001000 1i1 x 0x4270000000002000 +!! 3+ d> 0x4270000000001000 1i1 x 0x4270000000002001 +!! 3+ d=0< 0x4280000000000800 1i1 x 0x4280000000001000 +!! 3+ d> 0x4280000000000800 1i1 x 0x4280000000001001 +!! 3+ d=0< 0x4290000000000400 1i1 x 0x4290000000000800 +!! 3+ d> 0x4290000000000400 1i1 x 0x4290000000000801 +!! 3+ d=0< 0x42a0000000000200 1i1 x 0x42a0000000000400 +!! 3+ d> 0x42a0000000000200 1i1 x 0x42a0000000000401 +!! 3+ d=0< 0x42b0000000000100 1i1 x 0x42b0000000000200 +!! 3+ d> 0x42b0000000000100 1i1 x 0x42b0000000000201 +!! 3+ d=0< 0x42c0000000000080 1i1 x 0x42c0000000000100 +!! 3+ d> 0x42c0000000000080 1i1 x 0x42c0000000000101 +!! 3+ d=0< 0x42d0000000000040 1i1 x 0x42d0000000000080 +!! 3+ d> 0x42d0000000000040 1i1 x 0x42d0000000000081 +!! 3+ d=0< 0x42e0000000000020 1i1 x 0x42e0000000000040 +!! 3+ d> 0x42e0000000000020 1i1 x 0x42e0000000000041 +!! 3+ d=0< 0x42f0000000000010 1i1 x 0x42f0000000000020 +!! 3+ d> 0x42f0000000000010 1i1 x 0x42f0000000000021 +!! 3+ d=0< 0x4300000000000008 1i1 x 0x4300000000000010 +!! 3+ d> 0x4300000000000008 1i1 x 0x4300000000000011 +!! 3+ d=0< 0x4310000000000004 1i1 x 0x4310000000000008 +!! 3+ d> 0x4310000000000004 1i1 x 0x4310000000000009 +!! 3+ d=0< 0x4320000000000002 1i1 x 0x4320000000000004 +!! 3+ d> 0x4320000000000002 1i1 x 0x4320000000000005 +!! 3+ d=0< 0x4330000000000001 1i1 x 0x4330000000000002 +!! 3+ d> 0x4330000000000001 1i1 x 0x4330000000000003 +!! 3+ d0< 0x4340000000000001 1i1 x 0x4340000000000001 +!! 3+ d=> 0x4340000000000001 1i1 x 0x4340000000000002 +!! 3+ d=> 0x4340000000000001 1 x 0x4340000000000002 +!! 3+ d=0< 0x4350000000000001 1i1 x 0x4350000000000001 +!! 3+ d> 0x4350000000000001 1i1 x 0x4350000000000002 +A+ =0< 1pt 4i1 x 1pti2 +A+ > 1pt 4i1 x 1pti3 +A+ =0< 1pt 2i1 x 1pti1 +A+ > 1pt 2i1 x 1pti2 +A+ =0> -2 -1i1 x -3 +A+ < -2 -1i1 x -3i1 +A+ =0> -1pt -4i1 x -1pti2 +A+ < -1pt -4i1 x -1pti3 +A+ =0> -1pt -2i1 x -1pti1 +A+ < -1pt -2i1 x -1pti2 + +!! Pre-arithmetic shifts + carry propagation + +!! 40dfffc0 00000000 3ff00000 00000000 40e00000 00000000 +H+ ALL 1p15d(14)1 1 OK 1p15 +!! 3ff00000 00000000 40dfffc0 00000000 40e00000 00000000 +A+ ALL -1p15d(14)1 -1 OK -1p15 +A+ ALL 1ptd1 1 OK 1pt +A+ ALL -1ptd1 -1 OK -1pt +A+ ALL 1 15 OK 16 +A+ ALL -1 -15 OK -16 +!! carry, no propagation +!! 40000000 00000000 40dffec0 00000000 40dfff40 00000000 +H+ ALL 2 1ptd5 OK 1ptd3 +!! 40dffec0 00000000 40000000 00000000 40dfff40 00000000 +A+ ALL -2 -1ptd5 OK -1ptd3 +!! no shifting for denormals +A+ ALL Td1 0i1 OK T +A+ ALL -Td1 -0i1 OK -T +A+ ALL 0i(3)7 0i(3)1 OK T +A+ ALL -0i(3)7 -0i(3)1 OK -T +!! no carry +!! 40000000 00000000 40dfff40 00000000 40dfffc0 00000000 +H+ ALL 2 2p14d(14)1d(13)1 OK 2p14d(14)1 +!! 40dfff40 00000000 40000000 00000000 40dfffc0 00000000 +A+ ALL -2 -2p14d(14)1d(13)1 OK -2p14d(14)1 +A+ ALL 1 1ptd2 OK 1ptd1 +A+ ALL -1 -1ptd2 OK -1ptd1 +!! 40000000 00000000 40dfff40 00000000 40dfffc0 00000000 +H+ ALL 3 1ptd6 OK 1ptd3 +!! 40dfff40 00000000 40000000 00000000 40dfffc0 00000000 +A+ ALL -3 -1ptd6 OK -1ptd3 +!! 40000000 00000000 40dfff40 00000000 40dfffc0 00000000 +H+ ALL 1 14 OK 15 +!! 40dfff40 00000000 40000000 00000000 40dfffc0 00000000 +A+ ALL -1 -14 OK -15 +!! 40000000 00000000 40dfff40 00000000 40dfffc0 00000000 +H+ ALL 2 13 OK 15 +!! 40dfff40 00000000 40000000 00000000 40dfffc0 00000000 +A+ ALL -2 -13 OK -15 +!! no shifting for denormals +A+ ALL Td2 0i1 OK Td1 +A+ ALL -Td2 -0i1 OK -Td1 +A+ ALL 0i(2)3 0i(3)1 OK 0i(3)7 +A+ ALL -0i(2)3 -0i(3)1 OK -0i(3)7 + +!! Carry propagation from outward rounding round or sticky bit + +!! round bit +A+ > 2d1 1mt x 2 +A+ < -2d1 -1mt x -2 +!! "first" sticky bit +A+ > 4d1 1mt x 4 +A+ < -4d1 -1mt x -4 +!! sticky bit +A+ > 8d1 1mt x 8 +A+ < -8d1 -1mt x -8 +2+ =0> -Hm1d1 -1 x -Hm1d1 +2+ < -Hm1d1 -1 x -Hm1 +!! bff 00000 00000000 ffdfffff ffffffff ffdfffff ffffffff +!! bff 00000 00000000 ffdfffff ffffffff ffe00000 00000000 diff --git a/ir/tv/IeeeCC754/BasicOp/testsets/divide b/ir/tv/IeeeCC754/BasicOp/testsets/divide new file mode 100644 index 000000000..7f5cac797 --- /dev/null +++ b/ir/tv/IeeeCC754/BasicOp/testsets/divide @@ -0,0 +1,1107 @@ +!! This file contains precision and range independent test vectors for +!! the operation divide (/). The first character in each +!! test vector refers to the origin of the test vector +!! +!! 2: Jerome Coonen Version <2> +!! 3: Jerome Coonen Version <3> +!! @Phdthesis{ +!! author = {Coonen, J.T.}, +!! title = {Contributions to a proposed standard for binary +!! floating-point arithmetic}, +!! school = {University of California, Berkeley}, +!! year = {1984}} +!! +!! H: precision independent encoding of UCB/ough test vector +!! @Unpublished{ +!! author = {David G. Hough and others}, +!! title = {{UCBTEST}, a suite of programs for testing certain +!! difficult cases of {IEEE} 754 floating-point arithmetic}, +!! year = {1988}, +!! note = {Restricted public domain software from +!! http://netlib.bell-labs.com/netlib/fp/index.html}} +!! +!! A: Verdonk-Cuyt-Verschaeren (University of ntwerp) +!! @Article{ +!! author = {Verdonk, B. and Cuyt, A. and Verschaeren, D.}, +!! title = {A precision- and range-independent tool for testing +!! floating-point arithmetic {I}: basic operations, +!! square root and remainder}, +!! journal = {ACM TOMS}, +!! volume = {27}, +!! number = {1}, +!! pages = {92-118}, +!! year = {2001}} +!! note = {Under revision}} +!! +!! This file is part of the tool IeeeCC754 or IEEE 754 Compliance Checker. +!! It is a precision and range independent tool to test whether +!! an implementation of floating-point arithmetic (in hardware or +!! software) is compliant with the principles of the IEEE 754-854 +!! floating-point standards. You can find out more about the testing +!! tool IeeeCC754 and the syntax and semantics of the test vectors +!! at +!! http://win-www.uia.ac.be/u/cant/ieeecc754.html +!! +!! Last updated: +!! $Date$ +!! +!! Contact: +!! Brigitte.Verdonk@ua.ac.be +!! Department of Mathematics and Computer Science +!! University of Antwerp (UIA) +!! Universiteitsplein 1 +!! B2610 Antwerp, BELGIUM +!! +!! Medium size numbers +2/ ALL 1p15 1p5 OK 1p10 +A/ ALL -1p15 -1p5 OK 1p10 +2/ ALL 1p15 -1p5 OK -1p10 +2/ ALL -1p15 1p5 OK -1p10 +2/ ALL 1p120 1p20 OK 1p100 +A/ ALL -1p120 -1p20 OK 1p100 +2/ ALL -1p120 1p20 OK -1p100 +2/ ALL 1p120 -1p20 OK -1p100 +2/ ALL 1p63 1p23 OK 1p40 +A/ ALL -1p63 -1p23 OK 1p40 +A/ ALL -1p63 1p23 OK -1p40 +A/ ALL 1p63 -1p23 OK -1p40 +2/ ALL 1p47 1p13 OK 1p34 +A/ ALL -1p47 -1p13 OK 1p34 +A/ ALL -1p47 1p13 OK -1p34 +A/ ALL 1p47 -1p13 OK -1p34 +!! divisions by 10 +A/ ALL 40 10 OK 4 +A/ ALL -40 -10 OK 4 +A/ ALL -40 10 OK -4 +A/ ALL 40 -10 OK -4 +2/ ALL 32760 10 OK 3276 +2/ ALL 10000 10 OK 1000 +2/ ALL 10000 100 OK 100 +2/ ALL 10000 1000 OK 10 + +!! / 1 +2/ ALL 1 1 OK 1 +2/ ALL -1 -1 OK 1 +A/ ALL 1 -1 OK -1 +2/ ALL -1 1 OK -1 +2/ ALL 2 1 OK 2 +2/ ALL -2 -1 OK 2 +2/ ALL -2 1 OK -2 +2/ ALL 2 -1 OK -2 +2/ ALL Td1 1 OK Td1 +2/ ALL Td1 -1 OK -Td1 +A/ ALL 0i1 1 OK 0i1 +A/ ALL -0i1 -1 OK 0i1 +A/ ALL -0i1 1 OK -0i1 +A/ ALL 0i1 -1 OK -0i1 +!! / 2 +2/ ALL Hm1 2 OK Hm2 +2/ ALL Hm1 -2 OK -Hm2 +2/ ALL -Hm1d1 2 OK -Hm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+2/ ALL 0 -0 i -Q +2/ ALL -0 -0 i Q +!! zero versus denormal +! 0 / denormalized -> 0. +2/ ALL 0 0i1 OK 0 +2/ ALL -0 0i3 OK -0 +2/ ALL 0 -0i2 OK -0 +2/ ALL -0 -0i4 OK 0 +2/ ALL 0 Td1 OK 0 +2/ ALL -0 Td1 OK -0 +2/ ALL 0 -Td1 OK -0 +2/ ALL -0 -Td1 OK 0 +! Denormalized * 0 -> Inf, DivBy0 +2/ ALL 0i1 0 z H +2/ ALL -0i3 0 z -H +2/ ALL 0i2 -0 z -H +2/ ALL -0i4 -0 z H +2/ ALL Td1 0 z H +2/ ALL -Td1 0 z -H +2/ ALL Td1 -0 z -H +2/ ALL -Td1 -0 z H +!! zero versus normal +! 0 / small_integer -> 0. +2/ ALL 0 1 OK 0 +2/ ALL -0 2 OK -0 +2/ ALL 0 -3 OK -0 +2/ ALL -0 -4 OK 0 +2/ ALL 0 5 OK 0 +2/ ALL -0 6 OK -0 +2/ ALL 0 -7 OK -0 +2/ ALL -0 -8 OK 0 +! Small_int / 0 -> Inf with DivBy0. +2/ ALL 1 0 z H +2/ ALL -2 0 z -H +2/ ALL 3 -0 z -H +2/ ALL -4 -0 z H +2/ ALL 5 0 z H +2/ ALL -6 0 z -H +2/ ALL 7 -0 z -H +2/ ALL -8 -0 z H +! 0 / huge -> 0. +2/ ALL 0 Hm1 OK 0 +2/ ALL -0 Hm2 OK -0 +2/ ALL 0 -Hm1 OK -0 +2/ ALL -0 -Hm2 OK 0 +2/ ALL 0 Hm1d1 OK 0 +2/ ALL -0 Hm2d1 OK -0 +2/ ALL 0 -Hm2d1 OK -0 +2/ ALL -0 -Hm1d1 OK 0 +! Huge / 0 -> Inf with DivBy0. +2/ ALL Hm1 0 z H +2/ ALL -Hm2 0 z -H +2/ ALL Hm1 -0 z -H +2/ ALL -Hm2 -0 z H +2/ ALL Hm1d1 0 z H +2/ ALL -Hm2d1 0 z -H +2/ ALL Hm2d1 -0 z -H +2/ ALL -Hm1d1 -0 z H +! 0 / tiny -> 0. +2/ ALL 0 T OK 0 +2/ ALL -0 Tp1 OK -0 +2/ ALL 0 -Tp1 OK -0 +2/ ALL -0 -T OK 0 +2/ ALL 0 Tp1d1 OK 0 +2/ ALL -0 Ti1 OK -0 +2/ ALL 0 -Ti1 OK -0 +2/ ALL -0 -Tp1d1 OK 0 +! Tiny / 0 -> Inf with DivBy0. +2/ ALL T 0 z H +2/ ALL -Tp1 0 z -H +2/ ALL Tp1 -0 z -H +2/ ALL -T -0 z H +2/ ALL Tp1d1 0 z H +2/ ALL -Ti1 0 z -H +2/ ALL Ti1 -0 z -H +2/ ALL -Tp1d1 -0 z H +!! zero versus infinity +! Inf / 0 --> Inf with no problem. +2/ ALL H 0 OK H +2/ ALL -H 0 OK -H +2/ ALL H -0 OK -H +2/ ALL -H -0 OK H +! 0 / Inf --> 0 with no problem. +2/ ALL 0 H OK 0 +2/ ALL -0 H OK -0 +2/ ALL 0 -H OK -0 +2/ ALL -0 -H OK 0 +!! zero versus NaN +2/ ALL Q 0 OK Q +2/ ALL Q -0 OK Q +2/ ALL 0 Q OK Q +2/ ALL -0 Q OK Q +!2/ ALL S 0 i Q +!2/ ALL S -0 i Q +!2/ ALL 0 S i Q +!2/ ALL -0 S i Q +!! infinity versus infinity +2/ ALL H H i Q +2/ ALL -H H i -Q +2/ ALL H -H i -Q +2/ ALL -H -H i Q +!! infinity versus denormal +! Inf / denormalized -> Inf. +2/ ALL H 0i1 OK H +2/ ALL -H 0i3 OK -H +2/ ALL H -0i2 OK -H +2/ ALL -H -0i4 OK H +2/ ALL H Td1 OK H +2/ ALL -H Td1 OK -H +2/ ALL H -Td1 OK -H +2/ ALL -H -Td1 OK H +! Denorm / Inf -> 0. +2/ ALL 0i1 H OK 0 +2/ ALL -0i3 H OK -0 +2/ ALL 0i2 -H OK -0 +2/ ALL -0i4 -H OK 0 +2/ ALL Td1 H OK 0 +2/ ALL -Td1 H OK -0 +2/ ALL Td1 -H OK -0 +2/ ALL -Td1 -H OK 0 +!! infinity versus normal +! Inf / small_integer -> Inf. +2/ ALL H 1 OK H +2/ ALL -H 2 OK -H +2/ ALL H -3 OK -H +2/ ALL -H -4 OK H +2/ ALL H 5 OK H +2/ ALL -H 6 OK -H +2/ ALL H -7 OK -H +2/ ALL -H -8 OK H +! Small_int / Inf -> 0. +2/ ALL 1 H OK 0 +2/ ALL -2 H OK -0 +2/ ALL 3 -H OK -0 +2/ ALL -4 -H OK 0 +2/ ALL 5 H OK 0 +2/ ALL -6 H OK -0 +2/ ALL 7 -H OK -0 +2/ ALL -8 -H OK 0 +! Huge / Inf -> 0. +2/ ALL Hm1 H OK 0 +2/ ALL -Hm2 H OK -0 +2/ ALL Hm1 -H OK -0 +2/ ALL -Hm2 -H OK 0 +2/ ALL Hm1d1 H OK 0 +2/ ALL -Hm2d1 H OK -0 +2/ ALL Hd1 -H OK -0 +2/ ALL -Hd1 -H OK 0 +! Inf / huge -> Inf. +2/ ALL H Hm1 OK H +2/ ALL -H Hm2 OK -H +2/ ALL H -Hm1 OK -H +2/ ALL -H -Hm2 OK H +2/ ALL H Hm1d1 OK H +2/ ALL H -Hm2d1 OK -H +2/ ALL H -Hd1 OK -H +2/ ALL -H -Hd1 OK H +! Inf / tiny -> Inf. +2/ ALL H T OK H +2/ ALL -H Tp1 OK -H +2/ ALL H -Tp1 OK -H +2/ ALL -H -T OK H +2/ ALL H Tp1d1 OK H +2/ ALL -H Ti1 OK -H +2/ ALL H -Ti1 OK -H +2/ ALL -H -Tp1d1 OK H +! Tiny / Inf -> 0. +2/ ALL T H OK 0 +2/ ALL -Tp1 H OK -0 +2/ ALL Tp1 -H OK -0 +2/ ALL -T -H OK 0 +2/ ALL Tp1d1 H OK 0 +2/ ALL -Ti1 H OK -0 +2/ ALL Ti1 -H OK -0 +2/ ALL -Tp1d1 -H OK 0 +!! infinity versus NaN +2/ ALL Q H OK Q +2/ ALL Q -H OK Q +2/ ALL H Q OK Q +2/ ALL -H Q OK Q +!2/ ALL S H i Q +!2/ ALL S -H i Q +!2/ ALL H S i Q +!2/ ALL -H S i Q +!! NaN versus NaN +2/ ALL Q Q OK Q +!2/ ALL Q S i Q +!2/ ALL S Q i Q +!2/ ALL S S i Q +!! NaN versus denormal +2/ ALL Td1 Q OK Q +2/ ALL -Td1 Q OK Q +2/ ALL Q Td1 OK Q +2/ ALL Q -Td1 OK Q +2/ ALL Q 0i1 OK Q +2/ ALL Q -0i1 OK Q +2/ ALL 0i1 Q OK Q +2/ ALL -0i1 Q OK Q +!2/ ALL Td1 S i Q +!2/ ALL -Td1 S i Q +!2/ ALL S Td1 i Q +!2/ ALL S -Td1 i Q +!2/ ALL S 0i1 i Q +!2/ ALL S -0i1 i Q +!2/ ALL 0i1 S i Q +!2/ ALL -0i1 S i Q +!! NaN versus normal +2/ ALL Q 1 OK Q +2/ ALL Q -1 OK Q +2/ ALL 1 Q OK Q +2/ ALL -1 Q OK Q +2/ ALL Q Hd1 OK Q +2/ ALL Q -Hd1 OK Q +2/ ALL Hd1 Q OK Q +2/ ALL -Hd1 Q OK Q +!2/ ALL S 1 i Q +!2/ ALL S -1 i Q +!2/ ALL 1 S i Q +!2/ ALL -1 S i Q +!2/ ALL S Hd1 i Q +!2/ ALL S -Hd1 i Q +!2/ ALL Hd1 S i Q +!2/ ALL -Hd1 S i Q + +!! exceptions +!! invalid and divide by zero, see special representations +!! inexact, overflow +!! exp. Z >= U +2/ => Hm1 1m1 xo H +2/ 0< Hm1 1m1 xo Hd1 +2/ => -Hm1 -1m1 xo H +2/ 0< -Hm1 -1m1 xo Hd1 +2/ =< Hm1 -1m1 xo -H +2/ =< -Hm1 1m1 xo -H +2/ 0> Hm1 -1m1 xo -Hd1 +2/ 0> -Hm1 1m1 xo -Hd1 +2/ => Hm9 Tp9 xo H +2/ 0< Hm9 Tp9 xo Hd1 +2/ => Hd1 0i1 xo H +2/ 0< Hd1 0i1 xo Hd1 +2/ => Hm1 Td1 xo H +2/ 0< Hm1 Td1 xo Hd1 +2/ => Hd1 1d1 xo H +2/ 0< Hd1 1d1 xo Hd1 +!! Result = Max. normal, round or sticky bit <> 0 +!! This combination is not possible +!! inexact, underflow +!! X - Y <= -B-t +!! Z = 0.0...0, round bit = 0 +A/ =0< T 2pt xu 0 +A/ > T 2pt xu 0i1 +A/ =0< -T -2pt xu 0 +A/ > -T -2pt xu 0i1 +A/ =0> T -2pt xu -0 +A/ < T -2pt xu -0i1 +A/ =0> -T 2pt xu -0 +A/ < -T 2pt xu -0i1 +!! denormal +A/ =0< 0i1 4 xu 0 +A/ > 0i1 4 xu 0i1 +A/ =0< -0i1 -4 xu 0 +A/ > -0i1 -4 xu 0i1 +A/ =0> 0i1 -4 xu -0 +A/ < 0i1 -4 xu -0i1 +A/ =0> -0i1 4 xu -0 +A/ < -0i1 4 xu -0i1 +! Tiny / huge -> underflow. +2/ =<0 0i1 Hd1 xu 0 +2/ > 0i1 Hd1 xu 0i1 +2/ =<0 -0i1 -Hd1 xu 0 +2/ > -0i1 -Hd1 xu 0i1 +2/ =0> 0i1 -Hd1 xu -0 +2/ < 0i1 -Hd1 xu -0i1 +2/ =0> -0i1 Hd1 xu -0 +2/ < -0i1 Hd1 xu -0i1 +!! X - Y = -B-t+1, round bit = 1, sticky bit = 1 +A/ 0< Tp1d1 1pt xu 0 +A/ => Tp1d1 1pt xu 0i1 +A/ 0< -Tp1d1 -1pt xu 0 +A/ => -Tp1d1 -1pt xu 0i1 +A/ 0> -Tp1d1 1pt xu -0 +A/ =< -Tp1d1 1pt xu -0i1 +A/ 0> Tp1d1 -1pt xu -0 +A/ =< Tp1d1 -1pt xu -0i1 +!! denormal +A/ 0< Td1 1ptm1 xu 0 +A/ => Td1 1ptm1 xu 0i1 +A/ 0< -Td1 -1ptm1 xu 0 +A/ => -Td1 -1ptm1 xu 0i1 +A/ 0> -Td1 1ptm1 xu -0 +A/ =< -Td1 1ptm1 xu -0i1 +A/ 0> Td1 -1ptm1 xu -0 +A/ =< Td1 -1ptm1 xu -0i1 +!! X - Y = -B-t+1, round bit = 1, sticky bits = 0 +A/ 0< 3mB 1pt xu 0 +A/ => 3mB 1pt xu 0i1 +A/ 0< -3mB -1pt xu 0 +A/ => -3mB -1pt xu 0i1 +A/ 0> -3mB 1pt xu -0 +A/ =< -3mB 1pt xu -0i1 +A/ 0> 3mB -1pt xu -0 +A/ =< 3mB -1pt xu -0i1 +!! denormal +A/ 0< 0i3 4 xu 0 +A/ => 0i3 4 xu 0i1 +A/ 0< -0i3 -4 xu 0 +A/ => -0i3 -4 xu 0i1 +A/ 0> -0i3 4 xu -0 +A/ =< -0i3 4 xu -0i1 +A/ 0> 0i3 -4 xu -0 +A/ =< 0i3 -4 xu -0i1 +!! X - Y = -B-t+1, round bit = 1, sticky bits = 1 +A/ 0< 5mBm1 1pt xu 0 +A/ => 5mBm1 1pt xu 0i1 +A/ 0< -5mBm1 -1pt xu 0 +A/ => -5mBm1 -1pt xu 0i1 +A/ 0> -5mBm1 1pt xu -0 +A/ =< -5mBm1 1pt xu -0i1 +A/ 0> 5mBm1 -1pt xu -0 +A/ =< 5mBm1 -1pt xu -0i1 +!! denormal +A/ 0< 0i5 8 xu 0 +A/ => 0i5 8 xu 0i1 +A/ 0< -0i5 -8 xu 0 +A/ => -0i5 -8 xu 0i1 +A/ 0> -0i5 8 xu -0 +A/ =< -0i5 8 xu -0i1 +A/ 0> 0i5 -8 xu -0 +A/ =< 0i5 -8 xu -0i1 +!! X - Y = -B-t+1, round bit = 1, sticky bit = 0, round to even +A/ =0< T 1pt xu 0 +A/ > T 1pt xu 0i1 +A/ =0< -T -1pt xu 0 +A/ > -T -1pt xu 0i1 +A/ =0> -T 1pt xu -0 +A/ < -T 1pt xu -0i1 +A/ =0> T -1pt xu -0 +A/ < T -1pt xu -0i1 +!! denormal +2/ =0< 0i1 2 xu 0 +2/ > 0i1 2 xu 0i1 +2/ =0< -0i1 -2 xu 0 +2/ > -0i1 -2 xu 0i1 +2/ =0> -0i1 2 xu -0 +2/ < -0i1 2 xu -0i1 +2/ =0> 0i1 -2 xu -0 +2/ < 0i1 -2 xu -0i1 +!! X - Y = -B-t+2, round bit = 1, sticky bit = 0, round to even +A/ 0< Tp1i(1)1 1pt xu 0i1 +A/ => Tp1i(1)1 1pt xu 0i2 +A/ 0< -Tp1i(1)1 -1pt xu 0i1 +A/ => -Tp1i(1)1 -1pt xu 0i2 +A/ 0> -Tp1i(1)1 1pt xu -0i1 +A/ =< -Tp1i(1)1 1pt xu -0i2 +A/ 0> Tp1i(1)1 -1pt xu -0i1 +A/ =< Tp1i(1)1 -1pt xu -0i2 +!! denormal +A/ 0< 0i3 2 xu 0i1 +A/ => 0i3 2 xu 0i2 +A/ 0< -0i3 -2 xu 0i1 +A/ => -0i3 -2 xu 0i2 +A/ 0> -0i3 2 xu -0i1 +A/ =< -0i3 2 xu -0i2 +A/ 0> 0i3 -2 xu -0i1 +A/ =< 0i3 -2 xu -0i2 +!! exp. Z = -B + denormalization loss => inexactness +A/ =0< Tp1d3 2 xu Td2 +A/ > Tp1d3 2 xu Td1 +A/ =0< -Tp1d3 -2 xu Td2 +A/ > -Tp1d3 -2 xu Td1 +A/ =0> -Tp1d3 2 xu -Td2 +A/ < -Tp1d3 2 xu -Td1 +A/ =0> Tp1d3 -2 xu -Td2 +A/ < Tp1d3 -2 xu -Td1 +A/ 0<= Ti(3)7i3 1p2i(1)1 xu 0i(4)5 +A/ > Ti(3)7i3 1p2i(1)1 xu 0i(4)5i1 +A/ 0< Ti(3)7i3 1pti(1)1 xu 0 +A/ >= Ti(3)7i3 1pti(1)1 xu 0i1 +!! denormal +A/ 0< Td1 2 xu 0i(1)1d1 +A/ => Td1 2 xu 0i(1)1 +A/ 0< -Td1 -2 xu 0i(1)1d1 +A/ => -Td1 -2 xu 0i(1)1 +A/ 0> -Td1 2 xu -0i(1)1d1 +A/ =< -Td1 2 xu -0i(1)1 +A/ 0> Td1 -2 xu -0i(1)1d1 +A/ =< Td1 -2 xu -0i(1)1 +!! exp. Z = -B + inexactness, no denormalization loss +2/ =0< T 1i1 xv Td1 +2/ > T 1i1 xu T +A/ =0< -T -1i1 xv Td1 +A/ > -T -1i1 xu T +2/ =0> -T 1i1 xv -Td1 +2/ < -T 1i1 xu -T +A/ =0> T -1i1 xv -Td1 +A/ < T -1i1 xu -T +2/ <=0 Ti1 1i2 xv Td1 +2/ > Ti1 1i2 xu T +2/ <=0 Ti2 1i6 xv Td4 +!! denormal +2/ =0< Td1 1i1 xv Td2 +A/ > Td1 1i1 xu Td1 +A/ =0< -Td1 -1i1 xv Td2 +A/ > -Td1 -1i1 xu Td1 +A/ =0> -Td1 1i1 xv -Td2 +A/ < -Td1 1i1 xu -Td1 +A/ =0> Td1 -1i1 xv -Td2 +A/ < Td1 -1i1 xu -Td1 +2/ >= Td2 1d2 xv Td1 +2/ >= Td9 1d2 xv Td8 +2/ <= -Td8 1d2 xv -Td7 +2/ <=0 Td1 1i2 xv Td3 +2/ > Td1 1i2 xu Td2 +!! exp. Z = -B + tininess after rounding +A/ > Ti(1)1d1 3m1 xu T +A/ = Ti(1)1d1 3m1 xu Td1 +A/ 0< Ti(1)1d1 3m1 xv Td1 +A/ < -Ti(1)1d1 3m1 xu -T +A/ = -Ti(1)1d1 3m1 xu -Td1 +A/ 0> -Ti(1)1d1 3m1 xv -Td1 +A/ => 1d1 Hm2 xu T +A/ <0 1d1 Hm2 xu Td1 +A/ =< -1d1 Hm2 xu -T +A/ >0 -1d1 Hm2 xu -Td1 +!! tininess before and after rounding +!! as though the exponent range were unbounded +2/ 0< Tp1d1 2 xu Td1 +2/ => Tp1d1 2 xu T +A/ 0< -Tp1d1 -2 xu Td1 +A/ => -Tp1d1 -2 xu T +A/ 0> -Tp1d1 2 xu -Td1 +A/ =< -Tp1d1 2 xu -T +2/ 0> Tp1d1 -2 xu -Td1 +A/ =< Tp1d1 -2 xu -T +!! inexact, see rounding properties below + +!! exact rounding +!! round bit = 0, sticky bit = 1 => inexact, round down +! Tricky divides based on power series expansions +! 1 / (1 + Nulp+) --> 1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1d1 1i4 x 1d9 +2/ 0 1d1 1i4 x 1d9 +2/ < 1d1 1i4 x 1d9 +2/ > 1d1 1i4 x 1d8 +2/ = 1d3 1i2 x 1d7 +2/ 0 1d3 1i2 x 1d7 +2/ < 1d3 1i2 x 1d7 +2/ > 1d3 1i2 x 1d6 +2/ = 1d2 1i3 x 1d8 +2/ 0 1d2 1i3 x 1d8 +2/ < 1d2 1i3 x 1d8 +2/ > 1d2 1i3 x 1d7 +! A few tricky cases. +A/ =0< -1d4 -1i1 x 1d6 +A/ > -1d4 -1i1 x 1d5 +A/ =0> -1d4 1i1 x -1d6 +A/ < -1d4 1i1 x -1d5 +A/ =0> 1d4 -1i1 x -1d6 +A/ < 1d4 -1i1 x -1d5 +!! 3ff7ffff ffffffff 3feffff fffffffe 3ff80000 00000000 +H/ 0< 3m1d1 1d2 x 3m1 +H/ => 3m1d1 1d2 x 3m1i1 +A/ 0< -3m1d1 -1d2 x 3m1 +A/ => -3m1d1 -1d2 x 3m1i1 +A/ 0> -3m1d1 1d2 x -3m1 +A/ =< -3m1d1 1d2 x -3m1i1 +A/ 0> 3m1d1 -1d2 x -3m1 +A/ =< 3m1d1 -1d2 x -3m1i1 +!! denormal +A/ =0< 0i(1)1 Ti1 x 1m1d2 +A/ > 0i(1)1 Ti1 x 1m1d1 +A/ =0< -0i(1)1 -Ti1 x 1m1d2 +A/ > -0i(1)1 -Ti1 x 1m1d1 +A/ =0> -0i(1)1 Ti1 x -1m1d2 +A/ < -0i(1)1 Ti1 x -1m1d1 +A/ =0> 0i(1)1 -Ti1 x -1m1d2 +A/ < 0i(1)1 -Ti1 x -1m1d1 +!! round bit = 0, sticky bit = 10 => inexact, round down +!! This combination is not possible +!! round bit = 0, sticky bit = 1 => inexact, round down +A/ =0< 3i2 1i1 x 3 +A/ > 3i2 1i1 x 3i1 +A/ =0< -3i2 -1i1 x 3 +A/ > -3i2 -1i1 x 3i1 +A/ =0> 3i2 -1i1 x -3 +A/ < 3i2 -1i1 x -3i1 +A/ =0> -3i2 1i1 x -3 +A/ < -3i2 1i1 x -3i1 +!! denormal +A/ =0< 0i(2)3i1 Ti1 x 3m2 +A/ > 0i(2)3i1 Ti1 x 3m2i1 +A/ =0< -0i(2)3i1 -Ti1 x 3m2 +A/ > -0i(2)3i1 -Ti1 x 3m2i1 +A/ =0> 0i(2)3i1 -Ti1 x -3m2 +A/ < 0i(2)3i1 -Ti1 x -3m2i1 +A/ =0> -0i(2)3i1 Ti1 x -3m2 +A/ < -0i(2)3i1 Ti1 x -3m2i1 +!! round bit = 1, sticky bit = 0 => inexact, round up +!! This combination is not possible +!! round bit = 1, sticky bit = 1 => inexact, round up +! 1 / (1 - Qu-) --> 1 + (Q/2 u+) + tiny. +2/ = 1 1d3 x 1i2 +2/ 0 1 1d3 x 1i1 +2/ < 1 1d3 x 1i1 +2/ > 1 1d3 x 1i2 +2/ = 1 1d5 x 1i3 +2/ 0 1 1d5 x 1i2 +2/ < 1 1d5 x 1i2 +2/ > 1 1d5 x 1i3 +2/ = 1 1d9 x 1i5 +2/ 0 1 1d9 x 1i4 +2/ < 1 1d9 x 1i4 +2/ > 1 1d9 x 1i5 +! 1 / (1 - Qu-) --> 1 + (Q/2 u+) + tiny. +2/ => 1 1d1 x 1i1 +2/ 0< 1 1d1 x 1 +2/ => -1 -1d1 x 1i1 +2/ 0< -1 -1d1 x 1 +2/ =< -1 1d1 x -1i1 +2/ 0> -1 1d1 x -1 +2/ =< 1 -1d1 x -1i1 +2/ 0> 1 -1d1 x -1 +! (1 - Mulp-) / (1 - Qulp-) --> +! Case M < Q: (1 - (M/2)ulp+) * (1 + (Q/2)ulp+ + ((Q/2)ulp+)^2 + tiny) --> +! 1 + ((Q-M)/2)ulp+ + (QQ-MQ)/4(ulp+)^2 + tiny --> +! 1 + (Q-M)/2ulp+ + tiny. +! M + Q = 3. +2/ = 1d1 1d2 x 1i1 +2/ 0 1d1 1d2 x 1 +2/ < 1d1 1d2 x 1 +2/ > 1d1 1d2 x 1i1 +! M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4 1d3 x 1d1 +2/ 0 1d4 1d3 x 1d2 +2/ < 1d4 1d3 x 1d2 +2/ > 1d4 1d3 x 1d1 +! M + Q = 11. +2/ = 1d8 1d3 x 1d5 +2/ 0 1d8 1d3 x 1d6 +2/ < 1d8 1d3 x 1d6 +2/ > 1d8 1d3 x 1d5 +2/ = 1d9 1d2 x 1d7 +2/ 0 1d9 1d2 x 1d8 +2/ < 1d9 1d2 x 1d8 +2/ > 1d9 1d2 x 1d7 +! M + Q = 12. +2/ = 1d8 1d4 x 1d4 +2/ 0 1d8 1d4 x 1d5 +2/ < 1d8 1d4 x 1d5 +2/ > 1d8 1d4 x 1d4 +! M + Q = 14. +2/ = 1d9 1d5 x 1d4 +2/ 0 1d9 1d5 x 1d5 +2/ < 1d9 1d5 x 1d5 +2/ > 1d9 1d5 x 1d4 +!! denormal +A/ => Td2 Tp1d1 x 1m1d3 +A/ 0< Td2 Tp1d1 x 1m1d4 +A/ => -Td2 -Tp1d1 x 1m1d3 +A/ 0< -Td2 -Tp1d1 x 1m1d4 +A/ =< -Td2 Tp1d1 x -1m1d3 +A/ 0> -Td2 Tp1d1 x -1m1d4 +A/ =< Td2 -Tp1d1 x -1m1d3 +A/ 0> Td2 -Tp1d1 x -1m1d4 diff --git a/ir/tv/IeeeCC754/BasicOp/testsets/multiply b/ir/tv/IeeeCC754/BasicOp/testsets/multiply new file mode 100644 index 000000000..942020bdd --- /dev/null +++ b/ir/tv/IeeeCC754/BasicOp/testsets/multiply @@ -0,0 +1,1319 @@ +!! This file contains precision and range independent test vectors for +!! the operation multiply (*). The first character in each +!! test vector refers to the origin of the test vector +!! +!! 2: Jerome Coonen Version <2> +!! 3: Jerome Coonen Version <3> +!! @Phdthesis{ +!! author = {Coonen, J.T.}, +!! title = {Contributions to a proposed standard for binary +!! floating-point arithmetic}, +!! school = {University of California, Berkeley}, +!! year = {1984}} +!! +!! H: precision independent encoding of UCB/ough test vector +!! @Unpublished{ +!! author = {David G. Hough and others}, +!! title = {{UCBTEST}, a suite of programs for testing certain +!! difficult cases of {IEEE} 754 floating-point arithmetic}, +!! year = {1988}, +!! note = {Restricted public domain software from +!! http://netlib.bell-labs.com/netlib/fp/index.html}} +!! +!! A: Verdonk-Cuyt-Verschaeren (University of ntwerp) +!! @Article{ +!! author = {Verdonk, B. and Cuyt, A. and Verschaeren, D.}, +!! title = {A precision- and range-independent tool for testing +!! floating-point arithmetic {I}: basic operations, +!! square root and remainder}, +!! journal = {ACM TOMS}, +!! volume = {27}, +!! number = {1}, +!! pages = {92-118}, +!! year = {2001}} +!! note = {Under revision}} +!! +!! This file is part of the tool IeeeCC754 or IEEE 754 Compliance Checker. +!! It is a precision and range independent tool to test whether +!! an implementation of floating-point arithmetic (in hardware or +!! software) is compliant with the principles of the IEEE 754-854 +!! floating-point standards. You can find out more about the testing +!! tool IeeeCC754 and the syntax and semantics of the test vectors +!! at +!! http://win-www.uia.ac.be/u/cant/ieeecc754.html +!! +!! Last updated: +!! $Date$ +!! +!! Contact: +!! Brigitte.Verdonk@ua.ac.be +!! Department of Mathematics and Computer Science +!! University of Antwerp (UIA) +!! Universiteitsplein 1 +!! B2610 Antwerp, BELGIUM +!!!! First some easy tests for consistency. +! Check out sign manipulation. +2* ALL 1 1 OK 1 +2* ALL -1 -1 OK 1 +2* ALL -1 1 OK -1 +2* ALL 1 2 OK 2 +2* ALL -1 -2 OK 2 +2* ALL -1 2 OK -2 +A* ALL 1 -2 OK -2 +2* ALL 2 3 OK 6 +2* ALL -2 -3 OK 6 +2* ALL -2 3 OK -6 +A* ALL 2 -3 OK -6 +2* ALL 3 3 OK 9 +2* ALL -3 -3 OK 9 +2* ALL -3 3 OK -9 +! 1.0 * various. +2* ALL 0i1 1 OK 0i1 +!! 3ff00000 000000000 00000000 00000001 00000000 00000001 +A* ALL -0i1 -1 OK 0i1 +A* ALL -0i1 1 OK -0i1 +A* ALL -1 0i1 OK -0i1 +A* ALL 0i2 1 OK 0i2 +A* ALL -0i2 -1 OK 0i2 +2* ALL -0i2 1 OK -0i2 +A* ALL -1 0i2 OK -0i2 +!! 3ff00000 000000000 80000000 00000002 80000000 00000002 +A* ALL 0i4 1 OK 0i4 +2* ALL -0i4 -1 OK 0i4 +!! bff00000 00000000 80000000 00000004 00000000 00000004 +A* ALL -0i4 1 OK -0i4 +A* ALL -1 0i4 OK -0i4 +A* ALL Tp1d2 1 OK Tp1d2 +A* ALL -Tp1d2 -1 OK Tp1d2 +2* ALL -Tp1d2 1 OK -Tp1d2 +A* ALL -1 Tp1d2 OK -Tp1d2 +!! 3ff00000 000000000 801fffff fffffffe 801fffff fffffffe +2* ALL 1 -0i9 OK -0i9 +2* ALL -1 0i9 OK -0i9 +A* ALL -1 -0i9 OK 0i9 +A* ALL 0i9 1 OK 0i9 +A* ALL 1 -Td1 OK -Td1 +A* ALL -1 Td1 OK -Td1 +!! bff0000000 00000000 800fffff ffffffff 000fffff ffffffff +H* ALL -1 -Td1 OK Td1 +A* ALL Td1 1 OK Td1 +A* ALL 1 -Ti1 OK -Ti1 +A* ALL -1 Ti1 OK -Ti1 +!! !! bff0000000 00000000 801000001 00100000 00000000 +H* ALL -1 -Ti1 OK Ti1 +A* ALL Ti1 1 OK Ti1 + +2* ALL 1 Tp1i3 OK Tp1i3 +2* ALL -1 Ti9 OK -Ti9 +2* ALL 1 Td3 OK Td3 + +! Exact cases huge and 2. +2* ALL 2 Hm1d1 OK Hd1 +A* ALL -2 -Hm1d1 OK Hd1 +2* ALL Hm1d1 -2 OK -Hd1 +2* ALL -Hm1d1 2 OK -Hd1 +A* ALL 2 Hm2i3 OK Hm1i3 +A* ALL -2 -Hm2i3 OK Hm1i3 +2* ALL 2 -Hm2i3 OK -Hm1i3 +A* ALL -2 Hm2i3 OK -Hm1i3 +A* ALL 2 Hm2i1 OK Hm1i1 +A* ALL -2 -Hm2i1 OK Hm1i1 +2* ALL -2 Hm2i1 OK -Hm1i1 +A* ALL 2 -Hm2i1 OK -Hm1i1 +2* ALL 2 Hm2 OK Hm1 +2* ALL Hm2 -2 OK -Hm1 +A* ALL 2 Hm2d1 OK Hm1d1 +A* ALL -2 -Hm2d1 OK Hm1d1 +2* ALL -2 Hm2d1 OK -Hm1d1 +A* ALL 2 -Hm2d1 OK -Hm1d1 +A* ALL 2 Hm2d3 OK Hm1d3 +A* ALL -2 -Hm2d3 OK Hm1d3 +2* ALL 2 -Hm2d3 OK -Hm1d3 +A* ALL -2 Hm2d3 OK -Hm1d3 +! Exact cases tiny and 2. +2* ALL 2 T OK Tp1 +A* ALL -2 -T OK Tp1 +2* ALL T -2 OK -Tp1 +A* ALL -T 2 OK -Tp1 +2* ALL 2 Ti1 OK Tp1i1 +A* ALL -2 -Ti1 OK Tp1i1 +2* ALL -2 Ti1 OK -Tp1i1 +A* ALL 2 -Ti1 OK -Tp1i1 +A* ALL 2 Ti3 OK Tp1i3 +A* ALL -2 -Ti3 OK +Tp1i3 +A* ALL -Ti3 -2 OK Tp1i3 +2* ALL 2 -Ti3 OK -Tp1i3 +2* ALL -2 Ti3 OK -Tp1i3 +A* ALL 2 Ti5 OK Tp1i5 +A* ALL -2 -Ti5 OK Tp1i5 +2* ALL 2 -Ti5 OK -Tp1i5 +A* ALL -2 Ti5 OK -Tp1i5 +A* ALL 2 Ti9 OK Tp1i9 +A* ALL -2 -Ti9 OK Tp1i9 +2* ALL -2 Ti9 OK -Tp1i9 +A* ALL 2 -Ti9 OK -Tp1i9 +! Exact cases huge and 4. +2* ALL 4 Hm2d1 OK Hd1 +2* ALL -4 Hm2d1 OK -Hd1 +2* ALL 4 -Hm2d1 OK -Hd1 +2* ALL -4 -Hm2d1 OK Hd1 +2* ALL Hm2d3 4 OK Hd3 +2* ALL Hm2d3 -4 OK -Hd3 +2* ALL -Hm2d3 4 OK -Hd3 +2* ALL -Hm2d3 -4 OK Hd3 +!! random exponents +!! 36a00000 00000000 41800000 00000000 38300000 00000000 +H* ALL 1m9 1p8 OK 1m1 +A* ALL -1m9 -1p8 OK 1m1 +A* ALL -1m9 1p8 OK -1m1 +A* ALL -1p8 1m9 OK -1m1 +A* ALL 1m3 1m6 OK 1m9 +A* ALL -1m3 -1m6 OK 1m9 +A* ALL -1m3 1m6 OK -1m9 +A* ALL -1m6 1m3 OK -1m9 +A* ALL 8 8p6 OK 8p9 +A* ALL -8 -8p6 OK 8p9 +A* ALL -8 8p6 OK -8p9 +A* ALL -8p6 8 OK -8p9 + +!! Special representations +!! zero versus zero +2* ALL 0 0 OK 0 +2* ALL -0 0 OK -0 +2* ALL -0 -0 OK 0 +!! zero versus denormal +2* ALL 0i1 0 OK 0 +A* ALL -0i1 -0 OK 0 +A* ALL -0i1 0 OK -0 +A* ALL -0 0i1 OK -0 +A* ALL 0 0i2 OK 0 +A* ALL -0 -0i2 OK 0 +2* ALL 0 -0i2 OK -0 +A* ALL -0 0i2 OK -0 +A* ALL 0i3 0 OK 0 +A* ALL -0i3 -0 OK 0 +2* ALL -0i3 0 OK -0 +A* ALL 0i3 -0 OK -0 +A* ALL 0 0i4 OK 0 +2* ALL -0 -0i4 OK 0 +A* ALL 0i4 -0 OK -0 +A* ALL -0i4 0 OK -0 +2* ALL 0 Td1 OK 0 +A* ALL -0 -Td1 OK 0 +2* ALL -Td1 0 OK -0 +!! zero versus normal +2* ALL 0 1 OK 0 +A* ALL -0 -1 OK 0 +A* ALL -0 1 OK -0 +A* ALL -1 0 OK -0 +2* ALL -2 0 OK -0 +A* ALL 0 3 OK 0 +A* ALL -0 -3 OK 0 +2* ALL 0 -3 OK -0 +A* ALL -0 3 OK -0 +A* ALL 4 0 OK 0 +2* ALL -4 -0 OK 0 +A* ALL -4 0 OK -0 +A* ALL -0 4 OK -0 +2* ALL 5 0 OK 0 +A* ALL -5 -0 OK 0 +A* ALL -5 0 OK -0 +A* ALL -0 5 OK -0 +A* ALL 6 0 OK 0 +A* ALL -6 -0 OK 0 +A* ALL -6 0 OK -0 +2* ALL -0 6 OK -0 +A* ALL 7 0 OK 0 +A* ALL -7 -0 OK 0 +A* ALL -7 0 OK -0 +A* ALL -0 7 OK -0 +A* ALL 8 0 OK 0 +A* ALL -8 -0 OK 0 +A* ALL -8 0 OK -0 +A* ALL -0 8 OK -0 +! 0 * huge -> 0. +2* ALL Hm1 0 OK 0 +A* ALL -Hm1 -0 OK 0 +A* ALL -Hm1 0 OK -0 +A* ALL -0 Hm1 OK -0 +A* ALL Hm2 0 OK 0 +A* ALL -Hm2 -0 OK 0 +2* ALL -Hm2 0 OK -0 +A* ALL -0 Hm2 OK -0 +A* ALL Hm1d1 0 OK 0 +2* ALL -Hm1d1 -0 OK 0 +A* ALL -Hm1d1 0 OK -0 +A* ALL -0 Hm1d1 OK -0 +A* ALL Hm2d1 0 OK 0 +A* ALL -Hm2d1 -0 OK 0 +2* ALL -Hm2d1 0 OK -0 +A* ALL -0 Hm2d1 OK -0 +A* ALL 0 Hd1 OK 0 +2* ALL -Hd1 -0 OK 0 +A* ALL -Hd1 0 OK -0 +2* ALL -0 Hd1 OK -0 +! 0 * tiny -> 0. +A* ALL 0 T OK 0 +A* ALL -T -0 OK 0 +A* ALL -T 0 OK -0 +A* ALL -0 T OK -0 +A* ALL 0 Tp1 OK 0 +A* ALL -Tp1 -0 OK 0 +2* ALL -Tp1 0 OK -0 +A* ALL Tp1 -0 OK -0 +2* ALL 0 Tp1d1 OK 0 +2* ALL -Tp1d1 -0 OK 0 +A* ALL -Tp1d1 0 OK -0 +A* ALL Tp1d1 -0 OK -0 +A* ALL 0 Ti1 OK 0 +A* ALL -Ti1 -0 OK 0 +2* ALL -Ti1 0 OK -0 +A* ALL Ti1 -0 OK -0 +!! zero versus infinity +2* ALL H 0 i Q +2* ALL -0 -H i Q +2* ALL -0 H i -Q +A* ALL 0 -H i -Q +!! zero versus NaN +2* ALL Q 0 OK Q +2* ALL Q -0 OK Q +!2* ALL S 0 i Q +!2* ALL S -0 i Q +!2* ALL 0 S i Q +!2* ALL -0 S i Q +!! infinity versus infinity +2* ALL H H OK H +2* ALL -H H OK -H +2* ALL -H -H OK H +!! infinity versus denormal +2* ALL 0i1 H OK H +A* ALL -0i1 -H OK H +A* ALL -0i1 H OK -H +A* ALL -H 0i1 OK -H +A* ALL 0i2 H OK H +A* ALL -0i2 -H OK H +A* ALL -0i2 H OK -H +A* ALL -H 0i2 OK -H +A* ALL 0i3 H OK H +A* ALL -0i3 -H OK H +2* ALL -0i3 H OK -H +A* ALL -H 0i3 OK -H +A* ALL 0i4 H OK H +A* ALL -0i4 -H OK H +A* ALL -0i4 H OK -H +A* ALL -H 0i4 OK -H +A* ALL Td1 H OK H +2* ALL -Td1 -H OK H +2* ALL -Td1 H OK -H +A* ALL -H Td1 OK -H +!! infinity versus normal +! Inf * small_integer -> Inf. +2* ALL H 1 OK H +2* ALL -2 H OK -H +2* ALL H -3 OK -H +2* ALL -4 -H OK H +2* ALL 5 H OK H +2* ALL -H 6 OK -H +2* ALL 7 -H OK -H +2* ALL -H -8 OK H +! Inf * huge -> Inf. +2* ALL Hm1 H OK H +2* ALL -Hm2 H OK -H +2* ALL H -Hm1 OK -H +2* ALL -H -Hm2 OK H +2* ALL H Hm1d1 OK H +2* ALL -Hm2d1 H OK -H +2* ALL H -Hd1 OK -H +2* ALL -Hd1 -H OK H +! Inf * tiny -> Inf. +2* ALL T H OK H +2* ALL -Tp1 H OK -H +2* ALL -H -T OK H +2* ALL H Tp1d1 OK H +2* ALL -Ti1 H OK -H +2* ALL -Tp1d1 -H OK H +!! infinity versus NaN +2* ALL Q H OK Q +2* ALL Q -H OK Q +!2* ALL S H i Q +!2* ALL S -H i Q +!2* ALL H S i Q +!2* ALL -H S i Q +!! NaN versus NaN +2* ALL Q Q OK Q +!2* ALL Q S i Q +!2* ALL S Q i Q +!2* ALL S S i Q +!! NaN versus denormal +2* ALL Td1 Q OK Q +2* ALL -Td1 Q OK Q +2* ALL Q 0i1 OK Q +2* ALL Q -0i1 OK Q +!2* ALL Td1 S i Q +!2* ALL -Td1 S i Q +!2* ALL S Td1 i Q +!2* ALL S -Td1 i Q +!2* ALL S 0i1 i Q +!2* ALL S -0i1 i Q +!2* ALL 0i1 S i Q +!2* ALL -0i1 S i Q +!! NaN versus normal +2* ALL Q 1 OK Q +2* ALL Q -1 OK Q +2* ALL Q Hd1 OK Q +2* ALL Q -Hd1 OK Q +!2* ALL S 1 i Q +!2* ALL S -1 i Q +!2* ALL 1 S i Q +!2* ALL -1 S i Q +!2* ALL S Hd1 i Q +!2* ALL S -Hd1 i Q +!2* ALL Hd1 S i Q +!2* ALL -Hd1 S i Q + +!! exceptions +!! invalid, see special representations +!! inexact, overflow +!! exp. Z >= U +2* => Hm1 2 xo H +2* 0< Hm1 2i1 xo Hd1 +2* 0< Hm1 6i1 xo Hd1 +2* 0< Hm1 6 xo Hd1 +2* => Hm1 Hm1 xo H +2* => Hm1i9 Hd6 xo H +2* 0< Hm1 Hm2i6 xo Hd1 +2* => Hm1 Hd2 xo H +2* => -5d2 -Hm1 xo H +2* 0< -5d2 -Hm1 xo Hd1 +2* => -9i1 -Hm1 xo H +2* 0< -7 -Hm1 xo Hd1 +2* => -3 -Hm1 xo H +2* => -Hm1i5 -Hm1i1 xo H +2* => -Hd1 -Hd1 xo H +2* 0< -Hm2d7 -Hd1 xo Hd1 +2* => -Hd3 -Hm1i1 xo H +2* => -Hd3 -3i1 xo H +2* 0< -Hd3 -3i1 xo Hd1 +2* =< -3d2 Hm1 xo -H +2* =< -7d7 Hm1 xo -H +2* =< -9 Hm1 xo -H +2* 0> -5 Hm1 xo -Hd1 +2* =< -Hd3 Hm1 xo -H +2* =< -Hm2d7 Hm1 xo -H +2* =< -Hm1d9 Hm2i1 xo -H +2* 0> -Hm2 Hm1 xo -Hd1 +2* 0> Hm1 -4i5 xo -Hd1 +2* 0> Hm1 -8i3 xo -Hd1 +2* 0> Hm1 -2 xo -Hd1 +2* =< Hm1 -Hm2i4 xo -H +2* =< Hm1 -Hm2 xo -H +2* =< Hm1 -Hm1 xo -H +2* 0> Hm1i9 -Hm2i2 xo -Hd1 +2* =< Hm1i9 -6i2 xo -H +2* 0> Hm1i9 -6i2 xo -Hd1 +!! exp. Z = U - 1 + carry +A* => 1i1 Hd1 xo H +A* 0< 1i1 Hd1 xo Hd1 +A* => -1i1 -Hd1 xo H +A* 0< -1i1 -Hd1 xo Hd1 +2* => 1i2 Hd2 xo H +2* 0< 1i2 Hd2 xo Hd1 +A* => -1i2 -Hd2 xo H +A* 0< -1i2 -Hd2 xo Hd1 +A* => 1i4 Hd4 xo H +A* 0< 1i4 Hd4 xo Hd1 +A* => -1i4 -Hd4 xo H +A* 0< -1i4 -Hd4 xo Hd1 +A* => 1i8 Hd8 xo H +A* 0< 1i8 Hd8 xo Hd1 +A* => -1i8 -Hd8 xo H +A* 0< -1i8 -Hd8 xo Hd1 +A* =< -1i1 Hd1 xo -H +A* 0> -1i1 Hd1 xo -Hd1 +A* =< -Hd1 1i1 xo -H +A* 0> -Hd1 1i1 xo -Hd1 +A* =< -1i2 Hd2 xo -H +A* 0> -1i2 Hd2 xo -Hd1 +A* =< -Hd2 1i2 xo -H +A* 0> -Hd2 1i2 xo -Hd1 +A* =< -1i4 Hd4 xo -H +A* 0> -1i4 Hd4 xo -Hd1 +A* =< -Hd4 1i4 xo -H +A* 0> -Hd4 1i4 xo -Hd1 +A* =< -1i8 Hd8 xo -H +A* 0> -1i8 Hd8 xo -Hd1 +A* =< -Hd8 1i8 xo -H +A* 0> -Hd8 1i8 xo -Hd1 +2* =< Hm1d3 -2i8 xo -H +2* 0> Hm1d3 -2i8 xo -Hd1 +!! Result = Max. normal, round bit = 0, sticky bit = 01 +!! even precisions +A* e =0< 1i(h+1)1d1 Hd(h)1i2 x Hd1 +A* e > 1i(h+1)1d1 Hd(h)1i2 xo H +A* e =0> 1i(h+1)1d1 -Hd(h)1i2 x -Hd1 +A* e < 1i(h+1)1d1 -Hd(h)1i2 xo -H +A* e =0> Hd(h)1i2 -1i(h+1)1d1 x -Hd1 +A* e < Hd(h)1i2 -1i(h+1)1d1 xo -H +!! odd precisions +A* o =0< 1i(h)1 Hd(h)2i1 x Hd1 +A* o > 1i(h)1 Hd(h)2i1 xo H +A* o =0> 1i(h)1 -Hd(h)2i1 x -Hd1 +A* o < 1i(h)1 -Hd(h)2i1 xo -H +!! Result = Max. normal, round bit = 0, sticky bit = 1 +!! even precisions +A* e =0< 1i(h)1 Hd(h)2i3 x Hd1 +A* e > 1i(h)1 Hd(h)2i3 xo H +A* e =0> 1i(h)1 -Hd(h)2i3 x -Hd1 +A* e < 1i(h)1 -Hd(h)2i3 xo -H +!! odd precisions +A* o =0< 1i(h)1d1 Hd(h)2i3 x Hd1 +A* o > 1i(h)1d1 Hd(h)2i3 xo H +A* o =0> 1i(h)1d1 -Hd(h)2i3 x -Hd1 +A* o < 1i(h)1d1 -Hd(h)2i3 xo -H +!! Result = Max. normal, round bit = 1, sticky bit = 0 => round to even +!! even precisions +!! This combination is only possible for precision-dependent cases +!! odd precisions +A* o 0< 1i(h+1)1 Hd(h+1)2 x Hd1 +A* o => 1i(h+1)1 Hd(h+1)2 xo H +A* o 0> 1i(h+1)1 -Hd(h+1)2 x -Hd1 +A* o =< 1i(h+1)1 -Hd(h+1)2 xo -H +!! Result = Max. normal, round bit = 1, sticky bit = 10 +A* => 2d4 Hm1i2 xo H +A* 0< 2d4 Hm1i2 x Hd1 +A* => -2d4 -Hm1i2 xo H +A* 0< -2d4 -Hm1i2 x Hd1 +A* =< -2d4 Hm1i2 xo -H +A* 0> -2d4 Hm1i2 x -Hd1 +A* =< -Hm1i2 2d4 xo -H +A* 0> -Hm1i2 2d4 x -Hd1 +!! Result = Max. normal, round bit = 1, sticky bit = 01 +!! even precisions +A* e 0< 1i(h+5)5 Hd(h+1)1i(h+4)3 x Hd1 +A* e => 1i(h+5)5 Hd(h+1)1i(h+4)3 xo H +A* e 0> 1i(h+5)5 -Hd(h+1)1i(h+4)3 x -Hd1 +A* e =< 1i(h+5)5 -Hd(h+1)1i(h+4)3 xo -H +!! odd precisions +A* o 0< 1i(h+1)1d1 Hd(h)1i2 x Hd1 +A* o => 1i(h+1)1d1 Hd(h)1i2 xo H +A* o 0> 1i(h+1)1d1 -Hd(h)1i2 x -Hd1 +A* o =< 1i(h+1)1d1 -Hd(h)1i2 xo -H +!! Result = Max. normal, round bit = 1, sticky bit = 1 +A* => 2d2 Hm1i1 xo H +A* 0< 2d2 Hm1i1 x Hd1 +A* => -2d2 -Hm1i1 xo H +A* 0< -2d2 -Hm1i1 x Hd1 +A* =< -2d2 Hm1i1 xo -H +A* 0> -2d2 Hm1i1 x -Hd1 +A* =< -Hm1i1 2d2 xo -H +A* 0> -Hm1i1 2d2 x -Hd1 +!! inexact, underflow +!! X + Y <= -B-t-1 => exp. Z <= -B-t +!! Z = 0.0...0, round bit = 0 +2* =0< T T xu 0 +A* > T T xu 0i1 +2* =0< -T -T xu 0 +A* > -T -T xu 0i1 +2* =0> -T T xu -0 +A* < -T T xu -0i1 +2* > T Tp1 xu 0i1 +A* =0< T Tp1 xu 0 +A* > -T -Tp1 xu 0i1 +A* =0< -T -Tp1 xu 0 +2* < -T Tp1 xu -0i1 +A* =0> -T Tp1 xu -0 +A* < T -Tp1 xu -0i1 +A* =0> T -Tp1 xu -0 +A* =0< Tp1 Tp1 xu 0 +A* > Tp1 Tp1 xu 0i1 +A* =0< -Tp1 -Tp1 xu 0 +2* > -Tp1 -Tp1 xu 0i1 +A* =0> -Tp1 Tp1 xu -0 +A* < -Tp1 Tp1 xu -0i1 +A* =0< 1mtm2 T xu 0 +A* > 1mtm2 T xu 0i1 +A* =0< -1mtm2 -T xu 0 +A* > -1mtm2 -T xu 0i1 +A* =0> -1mtm2 T xu -0 +A* < -1mtm2 T xu -0i1 +A* =0> 1mtm2 -T xu -0 +A* < 1mtm2 -T xu -0i1 +2* =0> -Td9 Tp1i3 xu -0 +2* =0> Td9 -Tp1i3 xu -0 +2* < -Td9 Tp1i3 xu -0i1 +2* < Td9 -Tp1i3 xu -0i1 +A* =0< Td9 Tp1i3 xu 0 +A* =0< -Td9 -Tp1i3 xu 0 +A* > Td9 Tp1i3 xu 0i1 +A* > -Td9 -Tp1i3 xu 0i1 +2* =0< Td1 Td2 xu 0 +2* =0< -Td1 -Td2 xu 0 +2* > Td1 Td2 xu 0i1 +2* > -Td1 -Td2 xu 0i1 +A* =0> -Td1 Td2 xu -0 +A* =0> Td1 -Td2 xu -0 +A* < -Td1 Td2 xu -0i1 +A* < Td1 -Td2 xu -0i1 +!! denormal +A* =0< 0i1 1m3 xu 0 +A* > 0i1 1m3 xu 0i1 +A* =0< -0i1 -1m3 xu 0 +A* > -0i1 -1m3 xu 0i1 +A* =0> -0i1 1m3 xu -0 +A* < -0i1 1m3 xu -0i1 +A* =0> 0i1 -1m3 xu -0 +A* < 0i1 -1m3 xu -0i1 +2* > 0i1 0i1 xu 0i1 +2* =0< 0i1 0i1 xu 0 +2* < 0i1 -0i1 xu -0i1 +2* =0> -0i1 0i1 xu -0 +A* > -0i1 -0i1 xu 0i1 +A* =0< -0i1 -0i1 xu 0 +!! X + Y = -B-t-1, exp. Z = -B-t, due to carry, +!! round bit = 0, sticky bits = 1 +A* =0< 1mtm1d1 Ti1 xu 0 +A* > 1mtm1d1 Ti1 xu 0i1 +A* =0< -1mtm1d1 -Ti1 xu 0 +A* > -1mtm1d1 -Ti1 xu 0i1 +A* =0> -1mtm1d1 Ti1 xu -0 +A* < -1mtm1d1 Ti1 xu -0i1 +A* =0> 1mtm1d1 -Ti1 xu -0 +A* < 1mtm1d1 -Ti1 xu -0i1 +!! X + Y = -B-t, exp. Z = -B-t, no carry +!! round bit = 0, sticky bits = 1 +A* =0< 1mtd1 T xu 0 +A* > 1mtd1 T xu 0i1 +A* =0< -1mtd1 -T xu 0 +A* > -1mtd1 -T xu 0i1 +A* =0> -1mtd1 T xu -0 +A* < -1mtd1 T xu -0i1 +A* =0> 1mtd1 -T xu -0 +A* < 1mtd1 -T xu -0i1 +!! denormal +A* =0< 0i1 1m2 xu 0 +A* > 0i1 1m2 xu 0i1 +A* =0< -0i1 -1m2 xu 0 +A* > -0i1 -1m2 xu 0i1 +A* =0> -0i1 1m2 xu -0 +A* < -0i1 1m2 xu -0i1 +A* =0> -1m2 0i1 xu -0 +A* < -1m2 0i1 xu -0i1 +!! X + Y = -B-t+2, exp. Z = -B-t+2, no carry +!! round bit = 0, sticky bits = 1 +A* =0< 0i1 3m1d1 xu 0i1 +A* > 0i1 3m1d1 xu 0i2 +A* =0< -0i1 -3m1d1 xu 0i1 +A* > -0i1 -3m1d1 xu 0i2 +A* =0> -0i1 3m1d1 xu -0i1 +A* < -0i1 3m1d1 xu -0i2 +A* =0> -3m1d1 0i1 xu -0i1 +A* < -3m1d1 0i1 xu -0i2 +!! 3ff7ffff ffffffff 80000000 00000001 80000000 00000001 +!! X + Y = -B-t+3, exp. Z = -B-t+3, no carry +!! round bit = 0, sticky bits = 1 +A* =0< 0i1 7m1d1 xu 0i3 +A* > 0i1 7m1d1 xu 0i4 +A* =0< -0i1 -7m1d1 xu 0i3 +A* > -0i1 -7m1d1 xu 0i4 +A* =0> -0i1 7m1d1 xu -0i3 +A* < -0i1 7m1d1 xu -0i4 +A* =0> -7m1d1 0i1 xu -0i3 +A* < -7m1d1 0i1 xu -0i4 +!! 400bffff ffffffff 80000000 00000001 800000 00000003 +!! X + Y = -B-t, exp. Z = -B-t-1, due to carry +!! Z = 0.0...0, round bit = 1, sticky bits = 0 +!! This combination is not possible +!! X + Y = -B-t+1, exp. Z = -B-t+1, no carry +!! Z = 0.0...0, round bit = 1, sticky bits = 0 +!! even result +A* =0< 1mt T xu 0 +A* > 1mt T xu 0i1 +A* =0< -1mt -T xu 0 +A* > -1mt -T xu 0i1 +A* =0> -1mt T xu -0 +A* < -1mt T xu -0i1 +A* =0> 1mt -T xu -0 +A* < 1mt -T xu -0i1 +!! denormal +2* > 0i1 1m1 xu 0i1 +2* =0< 0i1 1m1 xu 0 +A* > -0i1 -1m1 xu 0i1 +A* =0< -0i1 -1m1 xu 0 +2* < 1m1 -0i1 xu -0i1 +2* =0> 1m1 -0i1 xu -0 +!! bfe00000 00000001 000000000 00000001 80000000 00000001 +H* < -1m1 0i1 xu -0i1 +H* =0> -1m1 0i1 xu -0 +!! X + Y = -B-t+2, exp. Z = -B-t+2, no carry +!! Z = 0.0...01, round bit = 1, sticky bits = 0 +!! odd result +A* 0< 0i1 3m1 xu 0i1 +A* => 0i1 3m1 xu 0i2 +A* 0< -0i1 -3m1 xu 0i1 +A* => -0i1 -3m1 xu 0i2 +!! bff80000 00000000 80000000 00000001 00000000 00000002 +A* 0> 3m1 -0i1 xu -0i1 +A* =< 3m1 -0i1 xu -0i2 +A* 0> -3m1 0i1 xu -0i1 +A* =< -3m1 0i1 xu -0i2 +!! X + Y = -B-t+3, exp. Z = -B-t+3, no carry +!! Z = 0.0...01x, round bit = 1, sticky bits = 0 +!! even result +A* =0< 0i1 5m1 xu 0i2 +A* > 0i1 5m1 xu 0i3 +A* =0< -0i1 -5m1 xu 0i2 +A* > -0i1 -5m1 xu 0i3 +A* =0> 5m1 -0i1 xu -0i2 +A* < 5m1 -0i1 xu -0i3 +A* =0> -5m1 0i1 xu -0i2 +A* < -5m1 0i1 xu -0i3 +!! odd result +A* 0< 0i1 7m1 xu 0i3 +A* => 0i1 7m1 xu 0i4 +A* 0< -0i1 -7m1 xu 0i3 +A* => -0i1 -7m1 xu 0i4 +!! c00c0000 00000000 800000000 00000001 000000000 00000004 +A* 0> 7m1 -0i1 xu -0i3 +A* =< 7m1 -0i1 xu -0i4 +A* 0> -7m1 0i1 xu -0i3 +A* =< -7m1 0i1 xu -0i4 +!! X + Y = -B-t+1, exp. Z = -B-t+1, no carry +!! Z = 0.0...0, round bit = 1, sticky bit = 1 +A* 0< 5mtm2 T xu 0 +A* => 5mtm2 T xu 0i1 +A* 0< -5mtm2 -T xu 0 +A* => -5mtm2 -T xu 0i1 +A* 0> -5mtm2 T xu -0 +A* =< -5mtm2 T xu -0i1 +A* 0> -T 5mtm2 xu -0 +A* =< -T 5mtm2 xu -0i1 +!! denormal +A* 0< 0i1 1m1i1 xu 0 +A* => 0i1 1m1i1 xu 0i1 +A* 0< -0i1 -1m1i1 xu 0 +A* => -0i1 -1m1i1 xu 0i1 +A* 0> -0i1 1m1i1 xu -0 +A* =< -0i1 1m1i1 xu -0i1 +A* 0> -1m1i1 0i1 xu -0 +A* =< -1m1i1 0i1 xu -0i1 +!! X + Y = -B-t+2, exp. Z = -B-t+2, no carry +!! Z = 0.0..010, round bit = 1, sticky bit = 1 +A* 0< 5m1i1 0i1 xu 0i2 +A* => 5m1i1 0i1 xu 0i3 +A* 0< -5m1i1 -0i1 xu 0i2 +A* => -5m1i1 -0i1 xu 0i3 +!! c0040000 00000001 00000000 00000001 80000000 00000003 +H* 0> -5m1i1 0i1 xu -0i2 +H* =< -5m1i1 0i1 xu -0i3 +A* 0> -0i1 5m1i1 xu -0i2 +A* =< -0i1 5m1i1 xu -0i3 +!! X + Y = -B-t, exp. Z = -B-t+1, due to carry +!! Z = 0.0...0, round bit = 1, sticky bits = 1 +A* 0< 1mtm1i1 Tp1d1 xu 0 +A* => 1mtm1i1 Tp1d1 xu 0i1 +A* 0< -1mtm1i1 -Tp1d1 xu 0 +A* => -1mtm1i1 -Tp1d1 xu 0i1 +A* 0> -1mtm1i1 Tp1d1 xu -0 +A* =< -1mtm1i1 Tp1d1 xu -0i1 +A* 0> -Tp1d1 1mtm1i1 xu -0 +A* =< -Tp1d1 1mtm1i1 xu -0i1 +!! X + Y = -B-t+1, exp. Z = -B-t+1, no carry +!! Z = 0.0...0, round bit = 1, sticky bits = 10 +A* 0< 3mtm1 T xu 0 +A* => 3mtm1 T xu 0i1 +A* 0< -3mtm1 -T xu 0 +A* => -3mtm1 -T xu 0i1 +A* 0> -3mtm1 T xu -0 +A* =< -3mtm1 T xu -0i1 +A* 0> -T 3mtm1 xu -0 +A* =< -T 3mtm1 xu -0i1 +!! denormal +A* 0< 0i1 3m2 xu 0 +A* => 0i1 3m2 xu 0i1 +A* 0< -0i1 -3m2 xu 0 +A* => -0i1 -3m2 xu 0i1 +A* 0> -0i1 3m2 xu -0 +A* =< -0i1 3m2 xu -0i1 +A* 0> -3m2 0i1 xu -0 +A* =< -3m2 0i1 xu -0i1 +!! X + Y = -B-t, exp. Z = -B-t+1, due to carry +!! Z = 0.0...0, round bit = 1, sticky bits = 0 +!! This combination is not possible +!! X + Y = -B-t+1, exp. Z = -B-t+1, no carry +!! Z = 0.0...0, round bit = 1, sticky bits = 1 +A* 0< 7mtm2 T xu 0 +A* => 7mtm2 T xu 0i1 +A* 0< -7mtm2 -T xu 0 +A* => -7mtm2 -T xu 0i1 +A* 0> -7mtm2 T xu -0 +A* =< -7mtm2 T xu -0i1 +A* 0> -T 7mtm2 xu -0 +A* =< -T 7mtm2 xu -0i1 +!! denormal +A* 0< 0i1 3m2i1 xu 0 +A* => 0i1 3m2i1 xu 0i1 +A* 0< -0i1 -3m2i1 xu 0 +A* => -0i1 -3m2i1 xu 0i1 +A* 0> -0i1 3m2i1 xu -0 +A* =< -0i1 3m2i1 xu -0i1 +A* 0> -3m2i1 0i1 xu -0 +A* =< -3m2i1 0i1 xu -0i1 +2* 0< 0i1 1d1 xu 0 +2* => 0i1 1d1 xu 0i1 +A* 0< -0i1 -1d1 xu 0 +A* => -0i1 -1d1 xu 0i1 +2* 0> -0i1 1d1 xu -0 +A* =< -0i1 1d1 xu -0i1 +2* =< 0i1 -1d1 xu -0i1 +A* 0> 0i1 -1d1 xu -0 +!! X + Y = -B-t, exp. Z = -B-t+1, due to carry +!! Z = 0.0...0, round bit = 1, sticky bits = 1 +A* 0< 1mtd1 Tp1d1 xu 0 +A* => 1mtd1 Tp1d1 xu 0i1 +A* 0< -1mtd1 -Tp1d1 xu 0 +A* => -1mtd1 -Tp1d1 xu 0i1 +A* 0> -1mtd1 Tp1d1 xu -0 +A* =< -1mtd1 Tp1d1 xu -0i1 +A* 0> -Tp1d1 1mtd1 xu -0 +A* =< -Tp1d1 1mtd1 xu -0i1 +!! exp. Z = -B + denormalization loss => inexactness +!! denormal +2* 0< Td4 1i1 xu Td4 +A* => Td4 1i1 xv Td3 +A* 0< -Td4 -1i1 xu Td4 +A* => -Td4 -1i1 xv Td3 +A* 0> -Td4 1i1 xu -Td4 +A* =< -Td4 1i1 xv -Td3 +A* 0> -1i1 Td4 xu -Td4 +A* =< -1i1 Td4 xv -Td3 +!! exp. Z = -B + denormalization loss after carry => inexactness +A* => 3m2 Ti1 xv 0i(2)3i1 +A* 0< 3m2 Ti1 xu 0i(2)3 +A* => -3m2 -Ti1 xv 0i(2)3i1 +A* 0< -3m2 -Ti1 xu 0i(2)3 +A* =< -3m2 Ti1 xv -0i(2)3i1 +A* 0> -3m2 Ti1 xu -0i(2)3 +A* =< -Ti1 3m2 xv -0i(2)3i1 +A* 0> -Ti1 3m2 xu -0i(2)3 +!! exp. Z = -B + inexactness, no denormalization loss for = +A* 0< Td2 1i1 xu Td2 +2* => Td2 1i1 xv Td1 +A* 0< -Td2 -1i1 xu Td2 +A* => -Td2 -1i1 xv Td1 +A* 0> -Td2 1i1 xu -Td2 +A* =< -Td2 1i1 xv -Td1 +A* 0> -1i1 Td2 xu -Td2 +A* =< -1i1 Td2 xv -Td1 +A* 0< Td8 1i1 xu Td8 +2* => Td8 1i1 xv Td7 +A* 0< -Td8 -1i1 xu Td8 +A* => -Td8 -1i1 xv Td7 +A* 0> -Td8 1i1 xu -Td8 +A* =< -Td8 1i1 xv -Td7 +A* 0> -1i1 Td8 xu -Td8 +A* =< -1i1 Td8 xv -Td7 +A* 0< Td9 1i1 xu Td9 +A* => Td9 1i1 xv Td8 +A* 0< -Td9 -1i1 xu Td9 +A* => -Td9 -1i1 xv Td8 +A* 0> -Td9 1i1 xu -Td9 +2* =< -Td9 1i1 xv -Td8 +A* 0> -1i1 Td9 xu -Td9 +A* =< -1i1 Td9 xv -Td8 +A* 0< Ti1 1d6 xu Td3 +2* => Ti1 1d6 xv Td2 +A* 0< -Ti1 -1d6 xu Td3 +A* => -Ti1 -1d6 xv Td2 +A* 0> -Ti1 1d6 xu -Td3 +A* =< -Ti1 1d6 xv -Td2 +A* 0> -1d6 Ti1 xu -Td3 +A* =< -1d6 Ti1 xv -Td2 +A* =0< Td2 1d4 xv Td4 +2* > Td2 1d4 xu Td3 +A* =0< -Td2 -1d4 xv Td4 +A* > -Td2 -1d4 xu Td3 +A* =0> -Td2 1d4 xv -Td4 +A* < -Td2 1d4 xu -Td3 +A* =0> -1d4 Td2 xv -Td4 +A* < -1d4 Td2 xu -Td3 +!! exp. Z = -B after carry + inexactness, no denormalization loss for = +A* =0< 1m1d1 Ti3 xv 0i(1)1i1 +A* > 1m1d1 Ti3 xu 0i(1)1i2 +A* =0< -1m1d1 -Ti3 xv 0i(1)1i1 +A* > -1m1d1 -Ti3 xu 0i(1)1i2 +A* =0> -1m1d1 Ti3 xv -0i(1)1i1 +A* < -1m1d1 Ti3 xu -0i(1)1i2 +A* =0> -Ti3 1m1d1 xv -0i(1)1i1 +A* < -Ti3 1m1d1 xu -0i(1)1i2 +!! exp. Z = -B + tininess before rounding, not after rounding +!! round bit = 1 +2* 0< Td1 1i1 xu Td1 +2* => Td1 1i1 xw T +A* 0< -Td1 -1i1 xu Td1 +A* => -Td1 -1i1 xw T +!! 800fffff ffffffff 3ff00000 00000001 80100000 00000000 +H* 0> -Td1 1i1 xu -Td1 +2* =< -Td1 1i1 xw -T +A* 0> -1i1 Td1 xu -Td1 +A* =< -1i1 Td1 xw -T +A* 0< 1i8 Td8 xu Td1 +2* => 1i8 Td8 xw T +!! 000fffff fffffff8 3ff00000 00000008 00100000 00000000 +A* 0< -Td8 -1i8 xu Td1 +A* => -Td8 -1i8 xw T +A* 0> -Td8 1i8 xu -Td1 +A* =< -Td8 1i8 xw -T +A* 0> -1i8 Td8 xu -Td1 +A* =< -1i8 Td8 xw -T +!! 000fffff fffffff8 bff00000 00000008 80100000 00000000 +2* 0< Ti1 1d2 xu Td1 +!! 00100000 00000001 3fefffff fffffffe 00100000 0000000 +H* => Ti1 1d2 xw T +A* 0< -Ti1 -1d2 xu Td1 +A* => -Ti1 -1d2 xw T +A* 0> -Ti1 1d2 xu -Td1 +A* =< -Ti1 1d2 xw -T +A* 0> -1d2 Ti1 xu -Td1 +A* =< -1d2 Ti1 xw -T +A* 0< Ti2 1d4 xu Td1 +!! subsitute for 20000000 02000000 1fffffff fc000000 00100000 00000000 +H* => Ti2 1d4 xw T +A* 0< -Ti2 -1d4 xu Td1 +A* => -Ti2 -1d4 xw T +A* 0> -Ti2 1d4 xu -Td1 +A* =< -Ti2 1d4 xw -T +A* 0> -1d4 Ti2 xu -Td1 +A* =< -1d4 Ti2 xw -T +!! round bit = 0 +A* 0< 1m1i2 Tp1d5 xv Td1 +A* = 1m1i2 Tp1d5 xu Td1 +A* > 1m1i2 Tp1d5 xu T +A* 0< -1m1i2 -Tp1d5 xv Td1 +A* = -1m1i2 -Tp1d5 xu Td1 +A* > -1m1i2 -Tp1d5 xu T +A* 0> -1m1i2 Tp1d5 xv -Td1 +A* = -1m1i2 Tp1d5 xu -Td1 +A* < -1m1i2 Tp1d5 xu -T +A* 0> -Tp1d5 1m1i2 xv -Td1 +A* = -Tp1d5 1m1i2 xu -Td1 +A* < -Tp1d5 1m1i2 xu -T +!! tininess before and after rounding, +!! as though the exponent range were unbounded +2* 0< Tp1d1 1m1 xu Td1 +2* => Tp1d1 1m1 xu T +A* => -Tp1d1 -1m1 xu T +2* 0< -Tp1d1 -1m1 xu Td1 +2* 0> -Tp1d1 1m1 xu -Td1 +A* =< -Tp1d1 1m1 xu -T +A* 0> -1m1 Tp1d1 xu -Td1 +A* =< -1m1 Tp1d1 xu -T +! Exact and below denormalization threshold -- no underflow. +2* ALL T 1d2 OK Td1 +A* ALL -T -1d2 OK Td1 +A* ALL -T 1d2 OK -Td1 +A* ALL -1d2 T OK -Td1 +2* ALL Tp1d2 1m1 OK Td1 +A* ALL -Tp1d2 -1m1 OK Td1 +A* ALL -Tp1d2 1m1 OK -Td1 +A* ALL -1m1 Tp1d2 OK -Td1 +A* ALL Tp1d4 1m1 OK Td2 +2* ALL -Tp1d4 -1m1 OK Td2 +2* ALL -Tp1d4 1m1 OK -Td2 +A* ALL -1m1 Tp1d4 OK -Td2 +2* ALL Tp1d8 1m1 OK Td4 +A* ALL -Tp1d8 -1m1 OK Td4 +A* ALL -Tp1d8 1m1 OK -Td4 +A* ALL -1m1 Tp1d8 OK -Td4 +2* ALL 0i8 1m3 OK 0i1 +A* ALL -0i8 -1m3 OK 0i1 +2* ALL -0i8 1m3 OK -0i1 +A* ALL -1m3 0i8 OK -0i1 +2* ALL 0i6 1m1 OK 0i3 +A* ALL -0i6 -1m1 OK 0i3 +A* ALL -0i6 1m1 OK -0i3 +A* ALL -1m1 0i6 OK -0i3 +!! inexact, see rounding below + +!! exact rounding +!! round bit = 0, sticky bit = 1 => inexact, round down +!! carry +2* 0<= 3d1 1d1 x 3d2 +2* > 3d1 1d1 x 3d1 +A* 0<= -3d1 -1d1 x 3d2 +A* > -3d1 -1d1 x 3d1 +2* 0>= -3d1 1d1 x -3d2 +2* < -3d1 1d1 x -3d1 +A* 0>= -1d1 3d1 x -3d2 +A* < -1d1 3d1 x -3d1 +2* 0<= 5d1 1d1 x 5d2 +2* > 5d1 1d1 x 5d1 +2* 0<= -5d1 -1d1 x 5d2 +2* > -5d1 -1d1 x 5d1 +A* 0>= -5d1 1d1 x -5d2 +A* < -5d1 1d1 x -5d1 +A* 0>= 5d1 -1d1 x -5d2 +A* < 5d1 -1d1 x -5d1 +2* =0< 7d1 1d1 x 7d2 +2* > 7d1 1d1 x 7d1 +A* =0< -7d1 -1d1 x 7d2 +A* > -7d1 -1d1 x 7d1 +A* =0> -7d1 1d1 x -7d2 +A* < -7d1 1d1 x -7d1 +A* =0> -1d1 7d1 x -7d2 +A* < -1d1 7d1 x -7d1 +A* =0< Tp1d1 1d1 x Tp1d2 +A* > Tp1d1 1d1 x Tp1d1 +A* =0< -Tp1d1 -1d1 x Tp1d2 +A* > -Tp1d1 -1d1 x Tp1d1 +A* =0> -Tp1d1 1d1 x -Tp1d2 +A* < -Tp1d1 1d1 x -Tp1d1 +A* =0> -1d1 Tp1d1 x -Tp1d2 +A* < -1d1 Tp1d1 x -Tp1d1 +A* =0< Hm2d7 4d1 x Hd8 +A* > Hm2d7 4d1 x Hd7 +2* =0< -Hm2d7 -4d1 x Hd8 +2* > -Hm2d7 -4d1 x Hd7 +A* =0> -Hm2d7 4d1 x -Hd8 +A* < -Hm2d7 4d1 x -Hd7 +A* =0> -4d1 Hm2d7 x -Hd8 +A* < -4d1 Hm2d7 x -Hd7 +!! no carry +2* 0<= 1i1 1i1 x 1i2 +2* > 1i1 1i1 x 1i3 +2* 0<= -1i1 -1i1 x 1i2 +2* > -1i1 -1i1 x 1i3 +2* 0>= -1i1 1i1 x -1i2 +2* < -1i1 1i1 x -1i3 +2* =0< 1i2 1i1 x 1i3 +2* > 1i2 1i1 x 1i4 +2* =0< -1i2 -1i1 x 1i3 +2* > -1i1 -1i2 x 1i4 +2* =0> -1i2 1i1 x -1i3 +2* < -1i2 1i1 x -1i4 +A* =0> 1i2 -1i1 x -1i3 +A* < 1i2 -1i1 x -1i4 +2* =0< -1d1 -Hd1 x Hd2 +2* > -1d1 -Hd1 x Hd1 +!! denormal +A* =0< 0i(1)1i1 2i1 x Ti3 +A* > 0i(1)1i1 2i1 x Ti4 +A* =0< -0i(1)1i1 -2i1 x Ti3 +A* > -0i(1)1i1 -2i1 x Ti4 +A* =0> -0i(1)1i1 2i1 x -Ti3 +A* < -0i(1)1i1 2i1 x -Ti4 +A* =0> -2i1 0i(1)1i1 x -Ti3 +A* < -2i1 0i(1)1i1 x -Ti4 +!! round bit = 0, sticky bit = 10 => inexact, round down +!! carry +A* =0< 3d1 3 x 8i(3)1d1 +A* > 3d1 3 x 8i(3)1 +A* =0< -3d1 -3 x 8i(3)1d1 +A* > -3d1 -3 x 8i(3)1 +A* =0> -3d1 3 x -8i(3)1d1 +A* < -3d1 3 x -8i(3)1 +A* =0> -3 3d1 x -8i(3)1d1 +A* < -3 3d1 x -8i(3)1 +!! no carry +A* =0< 5 Hm3i1 x 5pB0m2i1 +A* > 5 Hm3i1 x 5pB0m2i2 +A* =0< -5 -Hm3i1 x 5pB0m2i1 +A* > -5 -Hm3i1 x 5pB0m2i2 +A* =0> -5 Hm3i1 x -5pB0m2i1 +A* < -5 Hm3i1 x -5pB0m2i2 +A* =0> -Hm3i1 5 x -5pB0m2i1 +A* < -Hm3i1 5 x -5pB0m2i2 +A* =0< 5mB0 2i1 x 5mB0p1i1 +A* > 5mB0 2i1 x 5mB0p1i2 +A* =0< -5mB0 -2i1 x 5mB0p1i1 +A* > -5mB0 -2i1 x 5mB0p1i2 +A* =0> -5mB0 2i1 x -5mB0p1i1 +A* < -5mB0 2i1 x -5mB0p1i2 +A* =0> -2i1 5mB0 x -5mB0p1i1 +A* < -2i1 5mB0 x -5mB0p1i2 +!! round bit = 0, sticky bit = 1 => inexact, round down +!! no carry +2* =0< 5i1 1i1 x 5i2 +2* > 5i1 1i1 x 5i3 +2* =0< -5i1 -1i1 x 5i2 +2* > -5i1 -1i1 x 5i3 +A* =0> -5i1 1i1 x -5i2 +A* < -5i1 1i1 x -5i3 +A* =0> -1i1 5i1 x -5i2 +A* < -1i1 5i1 x -5i3 +!! carry +A* =0< 7d1 1d2 x 7d3 +A* > 7d1 1d2 x 7d2 +A* =0< -7d1 -1d2 x 7d3 +A* > -7d1 -1d2 x 7d2 +A* =0> -7d1 1d2 x -7d3 +A* < -7d1 1d2 x -7d2 +A* =0> -1d2 7d1 x -7d3 +A* < -1d2 7d1 x -7d2 +A* =0< 1d1 1d2 x 1d3 +A* > 1d1 1d2 x 1d2 +A* =0< -1d1 -1d2 x 1d3 +A* > -1d1 -1d2 x 1d2 +A* =0> -1d1 1d2 x -1d3 +A* < -1d1 1d2 x -1d2 +A* =0> 1d1 -1d2 x -1d3 +A* < 1d1 -1d2 x -1d2 +A* =0< Hm1d1 1i1 x Hm1 +A* > Hm1d1 1i1 x Hm1i1 +A* =0< -Hm1d1 -1i1 x Hm1 +A* > -Hm1d1 -1i1 x Hm1i1 +2* =0> -Hm1d1 1i1 x -Hm1 +2* < -Hm1d1 1i1 x -Hm1i1 +A* =0> -1i1 Hm1d1 x -Hm1 +A* < -1i1 Hm1d1 x -Hm1i1 +A* =0< Hm2d1 2i1 x Hm1 +A* > Hm2d1 2i1 x Hm1i1 +A* =0< -Hm2d1 -2i1 x Hm1 +A* > -Hm2d1 -2i1 x Hm1i1 +2* =0> -Hm2d1 2i1 x -Hm1 +2* < -Hm2d1 2i1 x -Hm1i1 +A* =0> -2i1 Hm2d1 x -Hm1 +A* < -2i1 Hm2d1 x -Hm1i1 +A* =0< 5mB0i1 2i1 x 5mB0p1i2 +A* > 5mB0i1 2i1 x 5mB0p1i3 +A* =0< -5mB0i1 -2i1 x 5mB0p1i2 +A* > -5mB0i1 -2i1 x 5mB0p1i3 +A* =0> -5mB0i1 2i1 x -5mB0p1i2 +A* < -5mB0i1 2i1 x -5mB0p1i3 +A* =0> -2i1 5mB0i1 x -5mB0p1i2 +A* < -2i1 5mB0i1 x -5mB0p1i3 +!! round bit = 1, sticky bit = 0 +!! half-way cases, round to even +!! odd result +!! carry +A* => 3i4 7 x 21i4 +A* 0< 3i4 7 x 21i3 +A* => -3i4 -7 x 21i4 +A* 0< -3i4 -7 x 21i3 +A* =< -3i4 7 x -21i4 +A* 0> -3i4 7 x -21i3 +A* =< -7 3i4 x -21i4 +A* 0> -7 3i4 x -21i3 +!! no carry +A* => 3 1i1 x 3i2 +A* 0< 3 1i1 x 3i1 +A* => -3 -1i1 x 3i2 +A* 0< -3 -1i1 x 3i1 +A* =< -3 1i1 x -3i2 +A* 0> -3 1i1 x -3i1 +A* =< -1i1 3 x -3i2 +A* 0> -1i1 3 x -3i1 +!! denormal +A* => 1m1 Ti3 xu 0i(1)1i2 +A* 0< 1m1 Ti3 xu 0i(1)1i1 +A* => -1m1 -Ti3 xu 0i(1)1i2 +A* 0< -1m1 -Ti3 xu 0i(1)1i1 +A* =< -1m1 Ti3 xu -0i(1)1i2 +A* 0> -1m1 Ti3 xu -0i(1)1i1 +A* =< -Ti3 1m1 xu -0i(1)1i2 +A* 0> -Ti3 1m1 xu -0i(1)1i1 +!! even result +!! carry +A* =0< 3i4i8 7 x 21i8i2 +A* > 3i4i8 7 x 21i8i3 +A* =0< -3i4i8 -7 x 21i8i2 +A* > -3i4i8 -7 x 21i8i3 +A* =0> -3i4i8 7 x -21i8i2 +A* < -3i4i8 7 x -21i8i3 +A* =0> -7 3i4i8 x -21i8i2 +A* < -7 3i4i8 x -21i8i3 +!! no carry +A* =0< 3 1i3 x 3i4 +A* > 3 1i3 x 3i5 +A* =0< -3 -1i3 x 3i4 +A* > -3 -1i3 x 3i5 +A* =0> -3 1i3 x -3i4 +A* < -3 1i3 x -3i5 +A* =0> -1i3 3 x -3i4 +A* < -1i3 3 x -3i5 +!! denormal +A* > 1m1 Ti1 xu 0i(1)1i1 +A* =0< 1m1 Ti1 xu 0i(1)1 +A* > -1m1 -Ti1 xu 0i(1)1i1 +A* =0< -1m1 -Ti1 xu 0i(1)1 +A* < -1m1 Ti1 xu -0i(1)1i1 +A* =0> -1m1 Ti1 xu -0i(1)1 +A* < -Ti1 1m1 xu -0i(1)1i1 +A* =0> -Ti1 1m1 xu -0i(1)1 +!! round bit = 1, sticky bit = 10 => inexact, round up +!! carry +A* => 1i(2)1 2d2 x 2i(2)1d1 +A* 0< 1i(2)1 2d2 x 2i(2)1d2 +A* => -1i(2)1 -2d2 x 2i(2)1d1 +A* 0< -1i(2)1 -2d2 x 2i(2)1d2 +A* =< -1i(2)1 2d2 x -2i(2)1d1 +A* 0> -1i(2)1 2d2 x -2i(2)1d2 +A* =< -2d2 1i(2)1 x -2i(2)1d1 +A* 0> -2d2 1i(2)1 x -2i(2)1d2 +!! no carry +A* => 7 1i1 x 7i2 +A* 0< 7 1i1 x 7i1 +A* => -7 -1i1 x 7i2 +A* 0< -7 -1i1 x 7i1 +A* =< -7 1i1 x -7i2 +A* 0> -7 1i1 x -7i1 +A* =< -1i1 7 x -7i2 +A* 0> -1i1 7 x -7i1 +A* => 7mB0 4i1 x 7mB0p2i2 +A* 0< 7mB0 4i1 x 7mB0p2i1 +A* => -7mB0 -4i1 x 7mB0p2i2 +A* 0< -7mB0 -4i1 x 7mB0p2i1 +A* =< -7mB0 4i1 x -7mB0p2i2 +A* 0> -7mB0 4i1 x -7mB0p2i1 +A* =< -4i1 7mB0 x -7mB0p2i2 +A* 0> -4i1 7mB0 x -7mB0p2i1 +!! round bit = 1, sticky bit = 1 => inexact, round up +!! no carry +2* => 3i1 1i1 x 3i3 +2* 0< 3i1 1i1 x 3i2 +A* => -3i1 -1i1 x 3i3 +A* 0< -3i1 -1i1 x 3i2 +2* =< -3i1 1i1 x -3i3 +2* 0> -3i1 1i1 x -3i2 +A* =< -1i1 3i1 x -3i3 +A* 0> -1i1 3i1 x -3i2 +A* => 3i1 1i3 x 3i6 +A* 0< 3i1 1i3 x 3i5 +A* => -3i1 -1i3 x 3i6 +A* 0< -3i1 -1i3 x 3i5 +A* =< -3i1 1i3 x -3i6 +A* 0> -3i1 1i3 x -3i5 +A* =< -1i3 3i1 x -3i6 +A* 0> -1i3 3i1 x -3i5 +!! carry +2* => 3d1 1d2 x 3d2 +2* 0< 3d1 1d2 x 3d3 +A* => -3d1 -1d2 x 3d2 +A* 0< -3d1 -1d2 x 3d3 +A* =< -3d1 1d2 x -3d2 +A* 0> -3d1 1d2 x -3d3 +A* =< -1d2 3d1 x -3d2 +A* 0> -1d2 3d1 x -3d3 +2* => 7d1 1d4 x 7d4 +2* 0< 7d1 1d4 x 7d5 +A* => -7d1 -1d4 x 7d4 +A* 0< -7d1 -1d4 x 7d5 +A* =< -7d1 1d4 x -7d4 +A* 0> -7d1 1d4 x -7d5 +A* =< -1d4 7d1 x -7d4 +A* 0> -1d4 7d1 x -7d5 +A* => 3mB0i1 4i1 x 3mB0p2i3 +A* 0< 3mB0i1 4i1 x 3mB0p2i2 +A* => -3mB0i1 -4i1 x 3mB0p2i3 +A* 0< -3mB0i1 -4i1 x 3mB0p2i2 +A* =< -3mB0i1 4i1 x -3mB0p2i3 +A* 0> -3mB0i1 4i1 x -3mB0p2i2 +A* =< -4i1 3mB0i1 x -3mB0p2i3 +A* 0> -4i1 3mB0i1 x -3mB0p2i2 +!! round bit = 1, sticky bit = 1 => inexact, round up +!! no carry +2* => 7i1 1i1 x 7i3 +2* 0< 7i1 1i1 x 7i2 +A* => -7i1 -1i1 x 7i3 +A* 0< -7i1 -1i1 x 7i2 +2* =< -7i1 1i1 x -7i3 +2* 0> -7i1 1i1 x -7i2 +A* =< -1i1 7i1 x -7i3 +A* 0> -1i1 7i1 x -7i2 +!! 3fefffff fffffffe 3ff00000 00000001 3fefffff ffffffff +H* => 1d2 1i1 x 1 +A* 0< 1d2 1i1 x 1d1 +A* => -1d2 -1i1 x 1 +A* 0< -1d2 -1i1 x 1d1 +A* =< -1d2 1i1 x -1 +A* 0> -1d2 1i1 x -1d1 +A* =< -1i1 1d2 x -1 +A* 0> -1i1 1d2 x -1d1 +!! carry +2* => 3d1 1d3 x 3d3 +2* 0< 3d1 1d3 x 3d4 +A* => -3d1 -1d3 x 3d3 +A* 0< -3d1 -1d3 x 3d4 +A* =< -3d1 1d3 x -3d3 +A* 0> -3d1 1d3 x -3d4 +A* =< -1d3 3d1 x -3d3 +A* 0> -1d3 3d1 x -3d4 +A* => 7mB0i1 4i1 x 7mB0p2i3 +A* 0< 7mB0i1 4i1 x 7mB0p2i2 +A* => -7mB0i1 -4i1 x 7mB0p2i3 +A* 0< -7mB0i1 -4i1 x 7mB0p2i2 +A* =< -7mB0i1 4i1 x -7mB0p2i3 +A* 0> -7mB0i1 4i1 x -7mB0p2i2 +A* =< -4i1 7mB0i1 x -7mB0p2i3 +A* 0> -4i1 7mB0i1 x -7mB0p2i2 + +! Just below denormalization threshold. +2* ALL Td1 2 OK Tp1d2 +!! 40000000000 00000000 000fffff ffffffff 001fffff ffffffe +A* ALL -Td1 -2 OK Tp1d2 +2* ALL -Td1 2 OK -Tp1d2 +A* ALL -2 Td1 OK -Tp1d2 +2* ALL -2 Td3 OK -Tp1d6 +2* ALL -Td3 -2 OK Tp1d6 +2* ALL 2 -Td3 OK -Tp1d6 +A* ALL Td3 2 OK Tp1d6 +!! c0000000 00000000 800fffff fffffffd 001fffff fffffffa +2* ALL Td4 2 OK Tp1d8 +!! 40000000000 00000000 000fffff fffffffc 001fffff ffffff8 +A* ALL -Td4 -2 OK Tp1d8 +2* ALL Td4 -2 OK -Tp1d8 +A* ALL 2 -Td4 OK -Tp1d8 + +! Normalizing tinies. +!! * 2 +2* ALL 0i1 2 OK 0i2 +!! 4000000000 00000000 00000000 00000001 00000000 00000002 +A* ALL -0i1 -2 OK 0i2 +A* ALL 0i1 -2 OK -0i2 +A* ALL 2 -0i1 OK -0i2 +A* ALL 0i2 2 OK 0i4 +A* ALL -0i2 -2 OK 0i4 +A* ALL 0i2 -2 OK -0i4 +A* ALL 2 -0i2 OK -0i4 +A* ALL 0i3 2 OK 0i6 +A* ALL -0i3 -2 OK 0i6 +A* ALL 0i3 -2 OK -0i6 +A* ALL 2 -0i3 OK -0i6 +!! * 3 +A* ALL 3 0i1 OK 0i3 +A* ALL -3 -0i1 OK 0i3 +A* ALL 3 -0i1 OK -0i3 +A* ALL 0i1 -3 OK -0i3 +2* ALL 3 0i2 OK 0i6 +A* ALL -3 -0i2 OK 0i6 +A* ALL 3 -0i2 OK -0i6 +A* ALL 0i2 -3 OK -0i6 +A* ALL 3 0i3 OK 0i9 +A* ALL -3 -0i3 OK 0i9 +A* ALL 3 -0i3 OK -0i9 +A* ALL 0i3 -3 OK -0i9 +!! * 4 +A* ALL 4 0i1 OK 0i4 +A* ALL 4 -0i1 OK -0i4 +A* ALL -4 -0i1 OK 0i4 +A* ALL -4 0i1 OK -0i4 +2* ALL 4 0i2 OK 0i8 +A* ALL 4 -0i2 OK -0i8 +A* ALL -4 -0i2 OK 0i8 +A* ALL -4 0i2 OK -0i8 +!! * 5 +A* ALL -0i1 -5 OK 0i5 +!! 40040000 00000000 00000000 00000001 00000000 00000002 +H* ALL 5 0i1 OK 0i5 +2* ALL -0i1 5 OK -0i5 +!! 40140000 00000000 80000000 00000001 80000000 00000005 +A* ALL 0i1 -5 OK -0i5 +!! * medium +!! 00000000 00000001 43500000 00000000 00300000 00000000 +H* ALL 0i1 2pt OK Tp2 +H* ALL -0i1 -2pt OK Tp2 +H* ALL -0i1 2pt OK -Tp2 +H* ALL -2pt 0i1 OK -Tp2 +A* ALL 0i1 1ptm1 OK T +A* ALL -0i1 -1ptm1 OK T +A* ALL -0i1 1ptm1 OK -T +A* ALL -1ptm1 0i1 OK -T diff --git a/ir/tv/IeeeCC754/include/Bitstring.h b/ir/tv/IeeeCC754/include/Bitstring.h new file mode 100644 index 000000000..37518c58c --- /dev/null +++ b/ir/tv/IeeeCC754/include/Bitstring.h @@ -0,0 +1,297 @@ +/* +########################################################################## +# # +# Program: IeeeCC754 # +# # +# Description: # +# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range # +# independent tool to test whether an implementation of # +# floating-point arithmetic (in hardware or software) is compliant # +# with the principles of the IEEE 754-854 floating-point standards. # +# You can find out more about the testing tool IeeeCC754 at # +# # +# http://win-www.uia.ac.be/u/cant/ieeecc754.html # +# # +# This tool is in parts based on and greatly benefited from the # +# the program FPTEST developed by Jerome Coonen. For a full # +# description of the extensions to FPTEST and a reference to # +# the original Coonen program, please refer to the URL given above. # +# For the options available with the program IeeeCC754 and its # +# compatibility with David Hough's hexadecimal UCB format, we # +# also refer to the file readme.usage. # +# # +# Usage: see readme.usage # +# # +# Responsible authors: # +# Brigitte Verdonk # +# Annie Cuyt # +# # +# Contributors: # +# Johan Bogo (1998-1999) # +# Tim Gevers (10-12/2000) # +# Debby Ooms (1996-1997) # +# Geert Vermuyten (1996-1997) # +# Dennis Verschaeren (09/1996-06/2000) # +# # +# Copyright (C) 2000 University of Antwerp # +# # +# This program can be obtained from the authors, free, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. # +# # +# Contact: # +# Brigitte.Verdonk@uia.ua.ac.be # +# Department of Mathematics and Computer Science # +# University of Antwerp (UIA) # +# Universiteitsplein 1 # +# B2610 Antwerp, BELGIUM # +# # +########################################################################## + +Filename: + $RCSfile$ + +Last updated: + $Date$ + +*/ + +/*************************************************************************** +* This is a class definition for bitstrings. The bitstring is a array of type +* (class T). The use of templates is to specify the block size. Only use +* unsigned types to define the class T, because else the shift operations +* (especially right shift) won't work correct. +************************************************************************** */ + +#ifndef _BITSTRING_H +#define _BITSTRING_H + + +#include +#include + + +#define NO_ERR 500 +#define ERR_OUT_OF_BOUND 501 + + + +/*class definition*/ +/**This class has been created to simplify the manipulation of bits over some array of integers (unsigned longs). +The internal structure of the bitstring resembles a little endian structure, +because this concept simplifies the resizing of the bitstring. +\TEX{\begin{figure}[h] +\begin{center} +\includegraphics[totalheight=3cm]{InterneBitstr.eps} +\caption{Internal structure of Bitstring} +\end{center} +\end{figure}} +@author Bogo Johan*/ + + + +class Bitstring +{ +protected: + ///the bitstring + unsigned long * bitstr; + ///length of bitstring, + long length; + /// number of array elments + long lengthBlock; + ///number of bits in class T + long lengthT; + + + /// returns a unsigned long with the first res bits set. + unsigned long GetPattern(unsigned long rest); + + /** returns the first block of bitstr. It's only defined + to be used in PutByte so the xor-operator would work + properly.*/ + unsigned long Convert(); + +public: + /// Constructor, creates an empty bitstring + Bitstring(); + /**Constructor, creates a bitstring of size size. + @param size the default size*/ + Bitstring(unsigned long size); + /**Constructor,initiate the bitstring with the str as input + @param str the default value for the bitstring */ + Bitstring(char * str); + /// Copy constructor. + Bitstring(const Bitstring& copy); + ///Destructor + ~Bitstring(); + + /**Get the length of the bitstring. + @return length of the bitstring*/ + virtual unsigned long Length() const; + /**Change the length of the bitstring to "len". If "len" is + larger then the length, the bitstring is appended with 0, else + the bitstring is truncated to the new length "len" + @param len the new length of the bitstring + @return previous length + */ + virtual unsigned long Resize(unsigned long len); + + /**Get the bit value at position "bit" + @param bit position of the bit + @return the bit value \\ \begin{tabular}{rcl} 0 <= "bit" < length &->& The bit value\\ + else & -> &0\end{tabular} */ + int GetBit(long bit) const; + + /**Replace the bit value at position "bit" with the new "bitvalue" + @param bit posisition of the bit + @param bitvalue new value + @return Previous bit value*/ + int PutBit(unsigned long bit,unsigned int bitvalue); + + /* Replace the bit value at position "bit" with the 1 + @param bit position of the bit + @return Previous bit value*/ + int Set(long bit); + + /** Replace the bit value at position "bit" with the 0 + @param bit position of the bit + @return Previous bit value */ + int Clear(long bit); + + /** Clears the bitstring + @return Cleared bitstring */ + Bitstring ClearBitString(); + + /**Get the byte value at position "byte" + @param byte position of the byte + @return The byte value */ + void GetByte(unsigned long byte,Bitstring sub) const; + + /** Replace the byte value at position "byte" with the new "bytevalue" + @param byte position of the byte + @param bytevalue new value + @return: void // Previous byte value */ + void PutByte(unsigned long byte,Bitstring bytevalue); + + + /** Increase the bitstring value by 1 + @return Carry after most significant bit*/ + int Inc(); + + /** Decrease the bitstring value by 1 + @return \begin{tabular}{rcl} 1& -> &wrap around (negative)\\ + 0& -> &OK \end{tabular} */ + int Dec(); + + /**Converts a bitstring to a C-string + @return the converted bitstring\\ \begin{tabular}{ccl} length >0 & -> & The C-string\\ + else & -> & "Bitstring is empty" \end{tabular}*/ + virtual void BitstrToString(char str[256]) const; + + /** Converts a C-string to a bitstring + @param str the C-string to be converted + @return converted bitstring */ + virtual void StringToBitstr(char *str); + + /** Puts bitstring *this in front of b2 -> so the first bit of b2 + becomes the first bit of *thisb2 + @param b2 second bitstring + @return *this -> *thisb2 */ + void Concat(const Bitstring &b2); + + /* Returns the substring defined by position "begin" to "count" + @param begin the begining of the substring + @param count the length of the substring + @return substring from bitstring */ + // Bitstring SubBitstring (unsigned long begin, unsigned long count) const; + void SubBitstring(unsigned long begin, Bitstring &sub) const; + + /** Overloads the array operator. Returns/change block "n" + @param n block number + @return block "n" */ + unsigned long& operator [](unsigned long n) const; + + /**Overloads the assign operator. Makes the bistring equal to "copy" + @param copy the new bitstring + @return The changed bitstring */ + Bitstring& operator = (const Bitstring ©); + + /** Overloads the equal operator. + @param b second bitstring + @return \begin{tabular}{lcl} equal & -> &1\\ + not equal &->& 0 \end{tabular}*/ + int operator == (const Bitstring & b) const; + + /** Overloads the not equal operator. + @return \begin{tabular}{lcl} not equal& ->& 1\\ + equal & ->& 0 \end{tabular}*/ + int operator != (const Bitstring &b) const; + + /** Overloads the greater than operator. + @return \begin{tabular}{lcl} greater & ->& 1\\ + not greater & ->& 0\end{tabular} */ + int operator > (const Bitstring &b) const; + + /** Overloads the smaller than operator. + @return \begin{tabular}{lcl} smaller& ->& 1\\ + not smaller & ->& 0\end{tabular} */ + int operator < (const Bitstring &b) const; + + + /**Overloads the shift left operator. Shifts the bitstring "count" + bits to the left + @param count number of shifts + @return shifted bitstring */ + void operator <<(long count); + + /**Overloads the shift right operator. Shifts the bitstring "count" + bits to the righ + @param count number of shifts + @return shifted bitstring */ + void operator >>(unsigned long count ); + + + /**Overloads the bitwise and operator. Does a bitwise and with + "bitstr" and "bitst". Makes the size of bitst equal to the + bitstring. + @param bitst second bitstring + @return bitwised and -> *this \& bitst */ + Bitstring operator &( const Bitstring &bitst); + + /** Overloads the bitwise or operator. Does a bitwise or with + "bitstr" and "bitst". Makes the size of bitst equal to the + bitstring. + @param bitst second bitstring + @return bitwised or -> *this $|$ bitst */ + Bitstring operator |( const Bitstring &bitst); + + /** Overloads the bitwise xor operator. Does a bitwise xor with + "bitstr" and "bitst". Makes the size of bitst equal to the + bitstring. + @param bitst second bitstring + @return bitwised xor -> *this \^\ bitst */ + Bitstring operator ^( const Bitstring &bitst); + + /** Overloads the bitwise not operator. Does a bitwise not with + "bitstr". + @return bitwised not -> \cxxtilde(*this) */ + Bitstring operator ~(); + + /** Overloads the stream output operator. Converts the bitstring to a + C-string and returns it to "ostream". + @param outs the ouput stream + @param outstr the bitstring + @return outs -> converted bitstring*/ + friend ostream& operator << (ostream& outs,const Bitstring &outstr); + + /** Overloads the stream input operator. Converts the C-string to a + bitstring. + @param ins the input stream + @param instr the bitstring + @return ins */ + friend istream& operator >> (istream& ins, Bitstring &instr); +}; + +//@Include: Hex.h + +#endif diff --git a/ir/tv/IeeeCC754/include/DriverFloatRepr.h b/ir/tv/IeeeCC754/include/DriverFloatRepr.h new file mode 100644 index 000000000..9aedef5cf --- /dev/null +++ b/ir/tv/IeeeCC754/include/DriverFloatRepr.h @@ -0,0 +1,229 @@ +/* +########################################################################## +# # +# Program: IeeeCC754 # +# # +# Description: # +# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range # +# independent tool to test whether an implementation of # +# floating-point arithmetic (in hardware or software) is compliant # +# with the principles of the IEEE 754-854 floating-point standards. # +# You can find out more about the testing tool IeeeCC754 at # +# # +# http://win-www.uia.ac.be/u/cant/ieeecc754.html # +# # +# This tool is in parts based on and greatly benefited from the # +# the program FPTEST developed by Jerome Coonen. For a full # +# description of the extensions to FPTEST and a reference to # +# the original Coonen program, please refer to the URL given above. # +# For the options available with the program IeeeCC754 and its # +# compatibility with David Hough's hexadecimal UCB format, we # +# also refer to the file readme.usage. # +# # +# Usage: see readme.usage # +# # +# Responsible authors: # +# Brigitte Verdonk # +# Annie Cuyt # +# # +# Contributors: # +# Johan Bogo (1998-1999) # +# Tim Gevers (10-12/2000) # +# Debby Ooms (1996-1997) # +# Geert Vermuyten (1996-1997) # +# Dennis Verschaeren (09/1996-06/2000) # +# # +# Copyright (C) 2000 University of Antwerp # +# # +# This program can be obtained from the authors, free, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. # +# # +# Contact: # +# Brigitte.Verdonk@uia.ua.ac.be # +# Department of Mathematics and Computer Science # +# University of Antwerp (UIA) # +# Universiteitsplein 1 # +# B2610 Antwerp, BELGIUM # +# # +########################################################################## + +Filename: + $RCSfile$ + +Last updated: + $Date$ + +*/ + + +// MORE INFORMATION ON THE FUNCTIONS IN THIS HEADER FILE CAN BE FOUND +// ON THE WEBPAGE +// http://win-www.uia.ac.be/u/cant/ieeecc754.html +// ``Adapt IeeeCC754 to test your floating-point implementation'' + +// ---- +// Includes +// ---- + +#include +#include + +// ---- +// Includes and Defines specificly for testing MpIeee +// ---- +#ifdef MPIEEE_TEST +#include +#endif + +// ---- +// Includes and Defines specificly for testing FMLib +// ---- +#ifdef FMLIB_TEST +#include +#endif + +// ---- +// CLASS DEFINITION : DriverFloatRepr +// ---- + + +class DriverFloatRepr: public FP +{ +protected: + +void SetLibRound( ); +// call the appropriate functions to set the rounding mode +// on the target platform - see item (a) on webpage + +void SetLibEnvironment( ); +// call the appropriate functions to clear all floating-point +// exceptions on the target platform - see item (b) on webpage + +void GetLibExceptions( ); +// call the appropriate functions to read out exceptions generated +// by the target platform - see item (b) on webpage + +public: + +#ifndef FMLIB_TEST +// For testing FMLib we use other definitions +// -- +DriverFloatRepr::DriverFloatRepr( ) :FP( ) + {} + +DriverFloatRepr::DriverFloatRepr( int m,int e,int h ) :FP( m,e,h ) + {} + +DriverFloatRepr::DriverFloatRepr( Bitstring &fp,int m,int e,int h ) :FP( fp,m,e,h ) + {} + ; +#endif + +// If your target implementation is implemented in hardware, +// provide an implementation of the functions listed below for +// conversion between your hardware data types and DriverFloatRepr +// see item (c) on webpage and +// ftp://win-ftp.uia.ac.be/pub/cant/IeeeCC754/converting.pdf + +DriverFloatRepr( float f ); +DriverFloatRepr( double d ); +DriverFloatRepr( long double l ); +float tofloat( ); +double todouble( ); +long double tolongdouble( ); + + +// If your target implementation is implemented in software, +// provide an implementation of the functions listed below for +// conversion between your floating-point datatype and +// DriverFloatRepr (don't forget to replace MyDatatype by the +// appropriate identifier in this declaration) - see item (c) on +// webpage and +// ftp://win-ftp.uia.ac.be/pub/cant/IeeeCC754/converting.pdf + +DriverFloatRepr (void *val); +void* to(void *val); + + + +// +// Here is an example to test the multiprecision floating-point +// implementation MpIeee: + +#ifdef MPIEEE_TEST +// Functions that Convert MpIeee to DriverFloatRepr and vice-versa +//-- + +DriverFloatRepr ( const MpIeee &M ); +MpIeee to( ); + +#endif + +#ifdef FMLIB_TEST +// Functions specifically for Testing FMLib +// -- + +DriverFloatRepr::DriverFloatRepr( ); +DriverFloatRepr::DriverFloatRepr( int m,int e,int h ); +DriverFloatRepr::DriverFloatRepr( Bitstring &fp,int m,int e,int h ); +DriverFloatRepr::DriverFloatRepr( DriverFloatRepr& ); +void DriverFloatRepr::fromDriverFloatRepr( Bitstring& m,Bitstring& e,int h ); +void DriverFloatRepr::toDriverFloatRepr( Bitstring m,Bitstring e,int h, int signf ); +FmNumber value; +long Length; +char* byteToStr( long ); +void Reverse( Bitstring& ); +void SetOperations( ); + +#endif + +// provide implementaton of the functions listed below in the file +// BasicOperations/$PLATFORM/BasicOperationstest.cc +// see item (d) on webpage +// -- + +DriverFloatRepr operator + ( DriverFloatRepr &T ); +DriverFloatRepr operator - ( DriverFloatRepr &T ); +DriverFloatRepr operator * ( DriverFloatRepr &T ); +DriverFloatRepr operator / ( DriverFloatRepr &T ); +DriverFloatRepr operator % ( DriverFloatRepr &T ); +DriverFloatRepr sqrt( ); + +// provide implementation of the functions listed below in the file +// Conversions/$PLATFORM/Conversionstest.cc +// see item (d) on webpage +// -- + +DriverFloatRepr roundto ( int, int, int ); +DriverFloatRepr copyto ( int, int, int ); +DriverFloatRepr rint ( ); +DriverFloatRepr ri ( ) ; +DriverFloatRepr ru ( ) ; +DriverFloatRepr rI ( ) ; +DriverFloatRepr rU ( ) ; +DriverFloatRepr ci ( int, int, int ); +DriverFloatRepr cu ( int, int, int ); +DriverFloatRepr cI ( int, int, int ); +DriverFloatRepr cU ( int, int, int ); +DriverFloatRepr b2d ( int ); +DriverFloatRepr d2b ( ); + +// conversions between DriverFloatRepr and hardware integer +// data types; implementation is provided in the files +// BasicOperations/$PLATFORM/fpenv_$PLATFORM.cc +// and +// Conversions/$PLATFORM/fpenv_$PLATFORM.cc +// and should not be modified +// -- + +DriverFloatRepr( long i ); +DriverFloatRepr( unsigned long i ); +DriverFloatRepr( long long int i ); +DriverFloatRepr( unsigned long long int i ); +int toint( ); +unsigned int touint( ); +long long int tolonglong( ); +unsigned long long int toulonglong( ); + +}; diff --git a/ir/tv/IeeeCC754/include/Fp.h b/ir/tv/IeeeCC754/include/Fp.h new file mode 100644 index 000000000..dfd4b2f01 --- /dev/null +++ b/ir/tv/IeeeCC754/include/Fp.h @@ -0,0 +1,328 @@ +/* +########################################################################## +# # +# Program: IeeeCC754 # +# # +# Description: # +# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range # +# independent tool to test whether an implementation of # +# floating-point arithmetic (in hardware or software) is compliant # +# with the principles of the IEEE 754-854 floating-point standards. # +# You can find out more about the testing tool IeeeCC754 at # +# # +# http://win-www.uia.ac.be/u/cant/ieeecc754.html # +# # +# This tool is in parts based on and greatly benefited from the # +# the program FPTEST developed by Jerome Coonen. For a full # +# description of the extensions to FPTEST and a reference to # +# the original Coonen program, please refer to the URL given above. # +# For the options available with the program IeeeCC754 and its # +# compatibility with David Hough's hexadecimal UCB format, we # +# also refer to the file readme.usage. # +# # +# Usage: see readme.usage # +# # +# Responsible authors: # +# Brigitte Verdonk # +# Annie Cuyt # +# # +# Contributors: # +# Johan Bogo (1998-1999) # +# Tim Gevers (10-12/2000) # +# Debby Ooms (1996-1997) # +# Geert Vermuyten (1996-1997) # +# Dennis Verschaeren (09/1996-06/2000) # +# # +# Copyright (C) 2000 University of Antwerp # +# # +# This program can be obtained from the authors, free, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. # +# # +# Contact: # +# Brigitte.Verdonk@uia.ua.ac.be # +# Department of Mathematics and Computer Science # +# University of Antwerp (UIA) # +# Universiteitsplein 1 # +# B2610 Antwerp, BELGIUM # +# # +########################################################################## + +Filename: + $RCSfile$ + +Last updated: + $Date$ + +*/ + +/*************************************************************************** +* This is a class definition for floating point numbers (IEEE 754). +* It uses the bitstring class for storing the exponent and the mantissa. +************************************************************************** */ + +#ifndef _FP_H +#define _FP_H +#include + +#include +#include + +#define RM_NEAR 0 +#define RM_UP 2 +#define RM_DOWN 1 +#define RM_ZERO 3 + + +#define NOT_KNOWN 100 + +#ifndef MYBIG_ENDIAN + #define MYBIG_ENDIAN 101 +#endif + +#ifndef MYLITTLE_ENDIAN + #define MYLITTLE_ENDIAN 102 +#endif + +#define maxstr 5000 +// maximum chars for binary to decimal conversion + +/**This is an abstract class defining floating-points as described in the IEEE 754 standard. It uses the Bitstring class to represent the mantissa and exponent +separately. The hidden bit is always present in the mantissa and needs to be defined for input and output in a hexadecimal form.\\ +\\ +There are three functions that need to be overloaded: SetRound(), GetExceptions(), SetEnvironment(). The first one must set the rounding mode of the library, +according to the rounding mode stored in the environment \textit{fpEnv}. This +can be done by calling the function GetFPRound() which returns the value actual rounding mode. GetExceptions() needs to convert the exceptions stored in the +testing library to the exceptions located in the environment \textit{fpEnv}. +To set the exceptions in the environment the functions: SetFPDivByZero(), SetFPInvalid(), SetFPUnderflow(), SetFPOverflow(), SetFPInexact() can be used. +The last function SetEnvironment() must set the library default environment. + + +@author Bogo Johan*/ + +class FP +{ + +protected: + ///Little or Big Endian + static int Endian; + + /**The representation of a floating-point environment. \\ + Bit positions and values: \begin{itemize} + \item 0: divide by zero + \item 1: invalid + \item 2: underflow + \item 3: overflow + \item 4: inexact + \item 21 - 22 : rounding mode + \begin{itemize} + \item 00: round to nearest + \item 01: round up + \item 10: round down + \item 11: round to zero + \end{itemize} + \end{itemize} */ + static Bitstring fpEnv; + + ///The sign of the floating-point number + int sign; + ///Hidden bit (yes/no) + int hidden; + ///The size of the mantissa + int sizeMant; + ///The mantissa + Bitstring mant; + ///The exponent + Bitstring exp; + + + /**Checks if the hardware is big or little endian. This function is only + needed to correctly convert a FP to a hardware floating-point*/ + static void CheckEndian(); + + /**Set the library rounding mode. This member function needs to be + overloaded when testing a floating-point implementation. The tester should + call his library function(s) to set the rounding mode corresponding the + one saved in fpEnv.*/ + void SetLibRound(){}; + /**Get library exceptions. This member functions needs to be overloaded + when testing a floating-point implementation. The tester should call his + function(s) to get the occured exceptions in his library and set them in + the fpEnv with SetFPDivByZero(), SetFPInvalid(),...*/ + void GetLibExceptions(){}; + /**Get FP rounding mode stored in fpEnv + @return the rounding mode \\ \begin{tabular}{ccl} 0 &:& round to nearest $(RM\_NEAR)$ \\ + 1 &:& round up (RM\_UP) \\ + 2 &:& round down $(RM\_DOWN)$ \\ + 3 &:& round to zero $(RM\_ZERO)$ + \end{tabular} + */ + int GetFPRound(); + + ///Sets the divide by zero exception in fpEnv + void SetFPDivByZero(){fpEnv.Set(0);} + ///Sets the invalid exception in fpEnv + void SetFPInvalid() {fpEnv.Set(1);} + ///Sets the underflow exception in fpEnv + void SetFPUnderflow(){fpEnv.Set(2);} + ///Sets the overflow exception in fpEnv + void SetFPOverflow() {fpEnv.Set(3);} + ///Sets the inexact exception in fpEnv + void SetFPInexact() {fpEnv.Set(4);} + + + +public: + + ///The size of the exponent + int sizeExp; + ///decimal + char *decimal; // binary to decimal conversion + + ///Constructor + FP(); + /**Constructor setting the size of the exponent, the mantissa and the + hidden bit + @param sizeM the size of the mantissa + @param sizeE the size of the exponent + @param hiddenbit if there is a hidden bit (0: false / 1: true)*/ + FP(int sizeM, int sizeE,int hiddenbit=0); + /**Constructor setting the size of the exponent,the mantissa and the + hidden bit. It initializes the floating-point number with a bitstring. + The bitstring must have the following form (sign exp (h) mant) + @param fp a bitstring containing the hardware reprecentation + of a floating-point + @param sizeM the size of the mantissa + @param sizeE the size of the exponent + @param hiddenbit if there is a hidden bit (0: false / 1: true) */ + FP(Bitstring &fp,int sizeM, int sizeE,int hiddenbit=0); + /**Copy constructor + @param copy an other FP object*/ + FP(FP & copy); + + //Destructor + virtual~FP(){}; + + ///returns true (1) if there is a hidden bit + int Hidden(){return hidden;}; + /**returns or sets the sign + @param sgn the new sign \\ \begin{tabular}{rcl} 1 &:& negative \\ + 0 &:& positive \\ + -1 &:& no change + \end{tabular} + @return the current sign or the previous depending \it{sgn} + */ + int Sign(int sgn=-1); + + /**Returns the mantissa + @return the mantissa hidden bit included (if defined)*/ + Bitstring & GetMantissa(); + /**Returns the exponent + @return the exponent*/ + Bitstring & GetExponent(); + /**Sets the mantissa + @param mantissa the new mantissa including the hidden bit (if defined) + @return the previous mantissa*/ + Bitstring PutMantissa(Bitstring &mantissa); + /**Sets the exponent + @param exponent the new exponent. + @return the previous exponent.*/ + Bitstring PutExponent(Bitstring &exponent); + + /**Checks if the floating-point is a Zero + @return \begin{tabular}{rcl} 1 &:& is a Zero\\ + 0 &:& is not a Zero + \end{tabular}*/ + int IsZero(); + + /**Checks if the floating-point is a negative Zero + @return \begin{tabular}{rcl} 1 &:& is a neg Zero\\ + 0 &:& is not a neg Zero + \end{tabular}*/ + int IsNegZero(); + + /**Checks if the floating-point is a NaN + @return \begin{tabular}{rcl} 1 &:& is a NaN \\ + 0 &:& is not a NaN + \end{tabular}*/ + int IsNaN(); + /**Creates a quiet NaN */ + void CreateQFPNan(); + + /**Assignment operator + @param copy an other FP object to be copied + @return *this*/ + FP& operator = (const FP ©); + /**Assignment operator + @param copy an Bitstring object to be converted to a FP object + @return *this*/ + FP& operator = (const Bitstring ©); + + /**Set the default library environment rounding mode. This member function + needs to be overloaded when testing a floating-point implementation. The + tester should call his library function(s) to set the default library + environment. Normaly this means to clear the exception flags and restoring + the rounding mode to round to nearest.*/ + void SetLibEnvironment(){}; + + /** Sets the rounding mode in the fpEnv to rm + @param rm next values a defined \\ \begin{tabular}{rcl} 0 &:& round to nearest $(RM\_NEAR)$ \\ + 1 &:& round up (RM\_UP) \\ + 2 &:& round down $(RM\_DOWN)$ \\ + 3 &:& round to zero $(RM\_ZERO)$ + \end{tabular} + */ + void SetFPRound (int rm); + ///Clears the environment (fpEnv) + void ClearFPEnvironment(); + /**Returns the exceptions stored in fpEnv as a Bitstring + @return a Bitstring with next bit positions set, depending the exception \\\begin{tabular}{rcl} + 0 &:& divide by zero\\ + 1 &:& invalid\\ + 2 &:& underflow\\ + 3 &:& overflow\\ + 4 &:& inexact + \end{tabular} */ + void GetFPExceptions(Bitstring); + + + /**Chekcs if there has occured a divide by zero exception + @return\begin{tabular}{rcl} 1 &:& divide by zero exception\\ + 0 &:& no divide by zero exception + \end{tabular}*/ + int GetFPDivByZero(){return fpEnv.GetBit(0);} + /**chekcs if there has occured a invalid exception + @return\begin{tabular}{rcl} 1 &:& invalid exception \\ + 0 &:& no invalid exception + \end{tabular}*/ + int GetFPInvalid() {//cout << "fpEnv.GetBit(1)" << fpEnv.GetBit(1); + return fpEnv.GetBit(1);} + /**chekcs if there has occured a underflow exception + @return\begin{tabular}{rcl} 1 &:& underflow exception \\ + 0 &:& no underflow exception + \end{tabular}*/ + int GetFPUnderflow(){return fpEnv.GetBit(2);} + /**chekcs if there has occured a overflow exception + @return\begin{tabular}{rcl} 1 &:& overflow exception \\ + 0 &:& no overflow exception + \end{tabular}*/ + int GetFPOverflow() {return fpEnv.GetBit(3);} + /**chekcs if there has occured a inexact exception + @return\begin{tabular}{rcl} 1 &:& inexact exception \\ + 0 &:& no inexact exception + \end{tabular}*/ + int GetFPInexact() {return fpEnv.GetBit(4);} + int istiny(); + int isInf(); + int isNan(); + + ///Overloaded output operator + friend ostream& operator << (ostream& outs, FP &outstr); + + friend istream& operator >> (istream& ins, FP &instr); + +}; + +//@Include: MyFloat.h MyDouble.h MyQuad.h FpSim.h Bitstring.h UCB.h dlist.h stack.h ../Calculator/FPcalculator.h + +#endif diff --git a/ir/tv/IeeeCC754/include/Hex.h b/ir/tv/IeeeCC754/include/Hex.h new file mode 100644 index 000000000..92c3325d0 --- /dev/null +++ b/ir/tv/IeeeCC754/include/Hex.h @@ -0,0 +1,146 @@ +/* +########################################################################## +# # +# Program: IeeeCC754 # +# # +# Description: # +# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range # +# independent tool to test whether an implementation of # +# floating-point arithmetic (in hardware or software) is compliant # +# with the principles of the IEEE 754-854 floating-point standards. # +# You can find out more about the testing tool IeeeCC754 at # +# # +# http://win-www.uia.ac.be/u/cant/ieeecc754.html # +# # +# This tool is in parts based on and greatly benefited from the # +# the program FPTEST developed by Jerome Coonen. For a full # +# description of the extensions to FPTEST and a reference to # +# the original Coonen program, please refer to the URL given above. # +# For the options available with the program IeeeCC754 and its # +# compatibility with David Hough's hexadecimal UCB format, we # +# also refer to the file readme.usage. # +# # +# Usage: see readme.usage # +# # +# Responsible authors: # +# Brigitte Verdonk # +# Annie Cuyt # +# # +# Contributors: # +# Johan Bogo (1998-1999) # +# Tim Gevers (10-12/2000) # +# Debby Ooms (1996-1997) # +# Geert Vermuyten (1996-1997) # +# Dennis Verschaeren (09/1996-06/2000) # +# # +# Copyright (C) 2000 University of Antwerp # +# # +# This program can be obtained from the authors, free, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. # +# # +# Contact: # +# Brigitte.Verdonk@uia.ua.ac.be # +# Department of Mathematics and Computer Science # +# University of Antwerp (UIA) # +# Universiteitsplein 1 # +# B2610 Antwerp, BELGIUM # +# # +########################################################################## + +Filename: + $RCSfile$ + +Last updated: + $Date$ + +*/ + +/*************************************************************************** +* This is a class definition for hexadecimal input of the bitstrings class. +* Hex is inherited from bitstring, so there are no data members necessery. +* The only thing that has to be done is to define the functions that change +* in behaviour. +************************************************************************** */ +#ifndef _HEXSTR_H +#define _HEXSTR_H + + +#include +#include + +/*class definition*/ + +/** + This class manipulates the Bitstring class as a hexadecimal string of bits. + The only difference in the + hexadecimal representation is the length of the string, as it + is four times smaller than the binary representation. + + All the members are defined in the class Bitstring, therefore there are no + extra data members in this class. + + @author Bogo Johan + */ + +class Hex : public Bitstring +{ + +protected: + /** returns the binairy value of character v + @param v: character between 0-9 and A-F or a-F + @return: the binary value of v*/ + void GetBin(char v); + + /** returns the character value of the Bitstring b + @param b: binary value, from 0000-1111 + @return: the character value of b*/ + char GetHex(Bitstring& b) const; + + +public: + /// Constructor, creates empty Bitstring + Hex(); + + /** Constructor + @param size: specifies the initial size of the bitstring. + The size is multiplied by 4 for a bistring.*/ + Hex(unsigned long size); + + /**Constructor, initiates the object with str + @param hstr: the hexadecimal number in a string-format */ + Hex(char *hstr); + + /**Copy constructor + @param copy a Bitstring object */ + Hex(const Bitstring ©); + + ///Deconstructor + ~Hex(){}; + + + /** Get the length of the bitstring + @return: the length of the bitstring divided by 4*/ + unsigned long Length() const {return length/4;}; + + /** changes the length of the bitstring to \textit{len} *4. + If the new length is larger then before, the bitstring + is appended with 0, else the bitstring is truncated to + the new length. + @param len the new length of the Bitstring + @return the previous length. + */ + unsigned long Resize(unsigned long len); + + /**converts the Bitstring to a C-string. + @return the converted Bitstring*/ + void BitstrToString(char* out) const; + + /**converts a C-string to a bitstring. + @param hstr a C-string to be converted + @return the HexString*/ + void StringToBitstr(char *hstr); + +}; + +#endif diff --git a/ir/tv/IeeeCC754/include/UCB.h b/ir/tv/IeeeCC754/include/UCB.h new file mode 100644 index 000000000..b06d1ef97 --- /dev/null +++ b/ir/tv/IeeeCC754/include/UCB.h @@ -0,0 +1,1055 @@ +/* +########################################################################## +# # +# Program: IeeeCC754 # +# # +# Description: # +# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range # +# independent tool to test whether an implementation of # +# floating-point arithmetic (in hardware or software) is compliant # +# with the principles of the IEEE 754-854 floating-point standards. # +# You can find out more about the testing tool IeeeCC754 at # +# # +# http://win-www.uia.ac.be/u/cant/ieeecc754.html # +# # +# This tool is in parts based on and greatly benefited from the # +# the program FPTEST developed by Jerome Coonen. For a full # +# description of the extensions to FPTEST and a reference to # +# the original Coonen program, please refer to the URL given above. # +# For the options available with the program IeeeCC754 and its # +# compatibility with David Hough's hexadecimal UCB format, we # +# also refer to the file readme.usage. # +# # +# Usage: see readme.usage # +# # +# Responsible authors: # +# Brigitte Verdonk # +# Annie Cuyt # +# # +# Contributors: # +# Tarun Agarwal (05-07/2002) # +# Johan Bogo (1998-1999) # +# Tim Gevers (10-12/2000) # +# Debby Ooms (1996-1997) # +# Geert Vermuyten (1996-1997) # +# Dennis Verschaeren (09/1996-06/2000) # +# # +# Copyright (C) 2000 University of Antwerp # +# # +# This program can be obtained from the authors, free, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. # +# # +# Contact: # +# Brigitte.Verdonk@uia.ua.ac.be # +# Department of Mathematics and Computer Science # +# University of Antwerp (UIA) # +# Universiteitsplein 1 # +# B2610 Antwerp, BELGIUM # +# # +########################################################################## + +Filename: + $RCSfile$ + +Last updated: + $Date$ + +*/ + +#ifndef _UCB_H +#define _UCB_H + +// ---- +// Includes +// ---- +#include +#include +#include +#include +#include + +// ---- +// Defines +// ---- +#define BUF_LEN 1024 +#define FP_STR 256 + +#define NO_FLAGS_INEXACT 16 +#define NO_FLAGS_OVERFLOW 8 +#define NO_FLAGS_UNDERFLOW 4 +#define NO_FLAGS_INVALID 2 +#define NO_FLAGS_DIV_BY_ZERO 1 + +extern int ieee; + +template class UCB +{ + +protected: + + fstream infile, outfile,logfile; + char dest[ BUF_LEN ]; + strstream logstream; + + int line,sizeE,sizeM,hidden,dsizeE,dsizeM,dhidden,noFlags,signedZero,ieeeVector; + char operation[ 10 ],prec,rounding,compare[ 5 ],exceptions[ 10 ]; + T operand1,operand2,result; + int pre, post; // to accomodate '?' + unsigned int errors,warnings,skipped; + + void PrintError( T &res ); + +public: + + int signalu,notsignalu,signalv,signalw,notsignalv,notsignalw,nou,nov,now,allops; + + UCB( ); + ~UCB( ); + + void SetFPRound ( ); + + int OpenInput( char* filename ); + int OpenOutput( char* filename ); + int OpenLogFile( char* filename,int argc,char **argv ); + int ReadLine( char* str=NULL,int sZero=1, int nflags=0,int *lines=NULL ); + + char* GetOperation( ); + char GetPrecision( ); + char GetRounding( ); + char* GetCompare( ); + char* GetExceptions( ); + T & GetOperand1( ); + T & GetOperand2( ); + T & GetResult( ); + + char* DoLine( int tiny,int inf, int nan); + void Compare ( T &reslt ); + void Close( int tiny ); +}; + + +template +UCB::UCB( ) +{ + line = 0; + // result.SetEnvironment(); change BV + signalu = 0; + signalv = 0; + signalw = 0; + notsignalu = 0; + notsignalv = 0; + notsignalw = 0; + nou= 1; + nov = 1; + now = 1; + pre = post = 0; + errors = 0; + warnings = 0; + skipped = 0; + allops = 0; +} + +template +UCB::~UCB( ) +{} + + +template +int UCB::OpenInput( char* filename ) +{ + infile.open( filename,ios::in ); + if ( infile.good( ) ) + return 1; + + return 0; +} + +template +void UCB::Close( int tiny ) +{ + logfile << "Summary: " << endl; + logfile << "-------- " << endl; + + if ( tiny ) { // conclusion underflow + if ( ucb.nou ) { + if ( ucb.nov ) { + if ( !( ucb.now ) ) + logfile << "Warning: only 'w' underflow cases in the testset" << endl; + } else + if ( ucb.now ) + logfile << "Warning: only 'v' underflow cases in the testset" << endl; + else + logfile << "Warning: only 'v' and 'w' underflow cases in the testset" << endl; + } // if + else { + if ( ucb.nov ) { + if ( ucb.now ) { + logfile << "Warning: no special 'v' or 'w' underflow cases in the testset" << endl; + if ( ucb.signalu && !ucb.notsignalu ) + logfile << "Implementation signals underflow in case the result" << endl << "(1) is tiny after rounding and" << endl << "(2) suffers denormalization loss" << endl << "('u' - underflow)" << endl; + } else + logfile << "Warning: no special 'v' underflow cases in the testset" << endl; + } else { + if ( ucb.now ) { + logfile << "Warning: no special 'w' underflow cases in the testset" << endl; + if ( ( ucb.signalu && !ucb.notsignalu ) && ( ucb.signalv && !ucb.notsignalv ) ) + logfile << "Implementation signals underflow in case the result" << endl << "(1) is tiny after rounding and" << endl << "(2) raises the inexact exception" << endl << "('v' - underflow)" << endl; + } else if ( ucb.signalu && !ucb.notsignalu ) { + if ( ucb.signalw && !ucb.notsignalw ) + logfile << "Implementation signals underflow in case the result" << endl << "(1) is tiny before rounding and" << endl << "(2) raises the inexact exception" << endl << "('w' - underflow)" << endl; + else if ( ucb.signalv && !ucb.notsignalv ) + logfile << "Implementation signals underflow in case the result" << endl << "(1) is tiny after rounding and" << endl << "(2) raises the inexact exception"<< endl << "('v' - underflow)" << endl; + else + logfile << "Implementation signals underflow in case the result" << endl << "(1) is tiny after rounding and" << endl << "(2) suffers denormalization loss" << endl << "('u' - underflow)" << endl; + } // else + } // else + } // else + } // if tiny + + logfile << "Errors: " << errors << "/" << allops << endl; + logfile << "Warnings: " << warnings << "/" << allops << endl; + logfile << "Skipped: " << skipped << "/" << allops << endl; +} + +template +int UCB::OpenOutput( char* filename ) +{ + outfile.open( filename,ios::out ); + if ( outfile.good( ) ) + return 1; + + return 0; +} + +template +int UCB::OpenLogFile( char* filename,int argc, char **argv ) +{ + logfile.open( filename,ios::out ); + if ( logfile.good( ) ) { + logfile << "Testrun: "; + for ( int i = 0; i < argc;i++ ) + logfile << argv[ i ] << " "; + logfile << endl << endl << flush; + return 1; + } + + return 0; +} + +template +int UCB::ReadLine( char* str,int sZero,int nflags,int *lines ) +{ + int i,j,k,gotInput=0,count; + Hex tmphex,tmphex2; + Bitstring tmpbitstring,tmpbitstring2; + char buf[ BUF_LEN ],tmp[ FP_STR ]; + line++; + signedZero=sZero; + + pre = post = 0; + if( !str ) { + if ( !infile.eof( ) ) { + infile.getline( buf,BUF_LEN ); + if( strlen( buf ) !=0 ) + gotInput=1; + } + + if( nflags ) + noFlags = nflags; + } else { + strncpy( buf,str,strlen( str ) ); + gotInput=1; + line=*lines; + noFlags=nflags; + } + + + if( gotInput ) { + i=0; + while ( buf[ i ] != ' ' ) { + operation[ i ] =buf[ i ]; + i++; + } + + operation[ i ] ='\0'; + + if ( !isdigit( operation[ strlen( operation ) -1 ] ) ) { + prec= operation[ strlen( operation ) -1 ]; + operation[ strlen( operation ) -1 ] ='\0'; + switch ( prec ) { + case 's': + sizeE=8; + sizeM=23+1; + hidden=1; + ieeeVector=0; + break; + case 'S': + sizeE=8; + sizeM=23+1; + hidden=1; + ieeeVector=1; + break; + case 'd': + sizeE=11; + sizeM=52+1; + hidden=1; + ieeeVector=0; + break; + case 'D': + sizeE=11; + sizeM=52+1; + hidden=1; + ieeeVector=1; + break; + case 'l': + sizeE=15; + sizeM=64 + 1; + hidden=0; + ieeeVector=0; + break; + case 'L': + sizeE=15; + sizeM=64 + 1; + hidden=0; + ieeeVector=1; + break; + case 'q': + sizeE=15; + sizeM=112+1; + hidden=1; + ieeeVector=0; + break; + case 'Q': + sizeE=15; + sizeM=112+1; + hidden=1; + ieeeVector=1; + break; + case 'm': + sizeE=15; + sizeM=240 + 1; + hidden = 0; + ieeeVector=0; + break; + case 'M': + sizeE=15; + sizeM=240 + 1; + hidden = 0; + ieeeVector=1; + break; + } + } else { + + ieeeVector=0; // Cannot be ieeeVector! + + i--; + + while ( isdigit( buf[ i ] ) ) i--; // rewind + + i++; + operation[ i ] = '\0'; // ignore digit after operation + j = 0; + + while ( buf[ i ] != ' ' ) + tmp[ j++ ] =buf[ i++ ]; + + tmp[ j ] ='\0'; + sizeE = atoi( tmp ); + + while ( buf[ ++i ] == ' ' ); + + j = 0; + + while ( buf[ i ] != ' ' ) + tmp[ j++ ] =buf[ i++ ]; + + tmp[ j ] ='\0'; + hidden = atoi( tmp ); + + while ( buf[ ++i ] == ' ' ); + + j = 0; + + while ( buf[ i ] != ' ' ) + tmp[ j++ ] =buf[ i++ ]; + + tmp[ j ] ='\0'; + sizeM = atoi( tmp ); + sizeM++ ; // +1 for the sign + } + + while ( buf[ i ] == ' ' ) i++; + + // read destination format + if ( ( strncmp( operation,"rt",2 ) == 0 ) || ( strncmp( operation,"ct",2 ) == 0 ) ) { + if ( !isdigit( buf[ i ] ) ) { + prec = buf[ i ]; + switch ( prec ) { + case 's': + dsizeE=8; + dsizeM=23+1; + dhidden=1; + break; + case 'd': + dsizeE=11; + dsizeM=52+1; + dhidden=1; + break; + case 'l': + dsizeE=15; + dsizeM=64 + 1; + dhidden=0; + // cout << 'l' << endl; + break; + case 'q': + dsizeE=15; + dsizeM=112+1; + dhidden=1; + break; + case 'm': + dsizeE=15; + dsizeM=240 + 1; + dhidden = 0; + break; + } // switch + + i++; + while ( buf[ i ] == ' ' ) i++; + } // if + else { + j = 0; + + while ( buf[ i ] != ' ' ) + tmp[ j++ ] =buf[ i++ ]; + tmp[ j ] ='\0'; + dsizeE = atoi( tmp ); + + while ( buf[ ++i ] == ' ' ); + + j = 0; + while ( buf[ i ] != ' ' ) + tmp[ j++ ] = buf[ i++ ]; + tmp[ j ] ='\0'; + dhidden = atoi( tmp ); + + while ( buf[ ++i ] == ' ' ); + j = 0; + + while ( buf[ i ] != ' ' ) + tmp[ j++ ] =buf[ i++ ]; + tmp[ j ] ='\0'; + dsizeM = atoi( tmp ); + dsizeM++; + + } // else + + while ( buf[ i ] == ' ' ) i++; + } // if + else { + dsizeE = sizeE; + dhidden = hidden; + dsizeM = sizeM; + } // else + + rounding=buf[ i ]; + + while ( buf[ ++i ] == ' ' ); + + j=0; + + while ( buf[ i ] != ' ' ) + compare[ j++ ] =buf[ i++ ]; + + compare[ j ] ='\0'; + + while ( buf[ ++i ] == ' ' ); + + j=0; + while ( buf[ i ] != ' ' ) { + exceptions[ j++ ] =buf[ i++ ]; + exceptions[ j++ ] =' '; + } + exceptions[ j ] ='\0'; + + while ( buf[ ++i ] == ' ' ); + + if ( ( strncmp( operation,"ci",2 ) ==0 ) || + ( strncmp( operation,"cu",2 ) ==0 ) ) { + count = 32; // 32 bit integer + i += 2; // avoid 0x + + for ( j=0; j= 'a' ) && ( buf[ i ] <= 'f' ) ) ) + tmp[ j ] = buf[ i++ ]; + else { + tmp[ j ] = 0; + break; + } + } // for + + for ( ; j= 'a' ) && ( buf[ i ] <= 'f' ) ) ) + tmp[ j ] = buf[ i++ ]; + else { + tmp[ j ] = 0; + break; + } + } + for ( ; j