• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1------------------------------------------------------------------------
2-- abs.decTest -- decimal absolute value                              --
3-- Copyright (c) IBM Corporation, 1981, 2008.  All rights reserved.   --
4------------------------------------------------------------------------
5-- Please see the document "General Decimal Arithmetic Testcases"     --
6-- at http://www2.hursley.ibm.com/decimal for the description of      --
7-- these testcases.                                                   --
8--                                                                    --
9-- These testcases are experimental ('beta' versions), and they       --
10-- may contain errors.  They are offered on an as-is basis.  In       --
11-- particular, achieving the same results as the tests here is not    --
12-- a guarantee that an implementation complies with any Standard      --
13-- or specification.  The tests are not exhaustive.                   --
14--                                                                    --
15-- Please send comments, suggestions, and corrections to the author:  --
16--   Mike Cowlishaw, IBM Fellow                                       --
17--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
18--   mfc@uk.ibm.com                                                   --
19------------------------------------------------------------------------
20version: 2.59
21
22-- This set of tests primarily tests the existence of the operator.
23-- Additon, subtraction, rounding, and more overflows are tested
24-- elsewhere.
25
26precision:   9
27rounding:    half_up
28maxExponent: 384
29minexponent: -383
30extended: 1
31
32absx001 abs '1'      -> '1'
33absx002 abs '-1'     -> '1'
34absx003 abs '1.00'   -> '1.00'
35absx004 abs '-1.00'  -> '1.00'
36absx005 abs '0'      -> '0'
37absx006 abs '0.00'   -> '0.00'
38absx007 abs '00.0'   -> '0.0'
39absx008 abs '00.00'  -> '0.00'
40absx009 abs '00'     -> '0'
41
42absx010 abs '-2'     -> '2'
43absx011 abs '2'      -> '2'
44absx012 abs '-2.00'  -> '2.00'
45absx013 abs '2.00'   -> '2.00'
46absx014 abs '-0'     -> '0'
47absx015 abs '-0.00'  -> '0.00'
48absx016 abs '-00.0'  -> '0.0'
49absx017 abs '-00.00' -> '0.00'
50absx018 abs '-00'    -> '0'
51
52absx020 abs '-2000000' -> '2000000'
53absx021 abs '2000000'  -> '2000000'
54precision: 7
55absx022 abs '-2000000' -> '2000000'
56absx023 abs '2000000'  -> '2000000'
57precision: 6
58absx024 abs '-2000000' -> '2.00000E+6' Rounded
59absx025 abs '2000000'  -> '2.00000E+6' Rounded
60precision: 3
61absx026 abs '-2000000' -> '2.00E+6' Rounded
62absx027 abs '2000000'  -> '2.00E+6' Rounded
63
64absx030 abs '+0.1'            -> '0.1'
65absx031 abs '-0.1'            -> '0.1'
66absx032 abs '+0.01'           -> '0.01'
67absx033 abs '-0.01'           -> '0.01'
68absx034 abs '+0.001'          -> '0.001'
69absx035 abs '-0.001'          -> '0.001'
70absx036 abs '+0.000001'       -> '0.000001'
71absx037 abs '-0.000001'       -> '0.000001'
72absx038 abs '+0.000000000001' -> '1E-12'
73absx039 abs '-0.000000000001' -> '1E-12'
74
75-- examples from decArith
76precision: 9
77absx040 abs '2.1'     ->  '2.1'
78absx041 abs '-100'    ->  '100'
79absx042 abs '101.5'   ->  '101.5'
80absx043 abs '-101.5'  ->  '101.5'
81
82-- more fixed, potential LHS swaps/overlays if done by subtract 0
83precision: 9
84absx060 abs '-56267E-10'  -> '0.0000056267'
85absx061 abs '-56267E-5'   -> '0.56267'
86absx062 abs '-56267E-2'   -> '562.67'
87absx063 abs '-56267E-1'   -> '5626.7'
88absx065 abs '-56267E-0'   -> '56267'
89
90-- overflow tests
91maxexponent: 999999999
92minexponent: -999999999
93precision: 3
94absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded
95
96-- subnormals and underflow
97precision: 3
98maxexponent: 999
99minexponent: -999
100absx210 abs  1.00E-999        ->   1.00E-999
101absx211 abs  0.1E-999         ->   1E-1000   Subnormal
102absx212 abs  0.10E-999        ->   1.0E-1000 Subnormal
103absx213 abs  0.100E-999       ->   1.0E-1000 Subnormal Rounded
104absx214 abs  0.01E-999        ->   1E-1001   Subnormal
105-- next is rounded to Emin
106absx215 abs  0.999E-999       ->   1.00E-999 Inexact Rounded Subnormal Underflow
107absx216 abs  0.099E-999       ->   1.0E-1000 Inexact Rounded Subnormal Underflow
108absx217 abs  0.009E-999       ->   1E-1001   Inexact Rounded Subnormal Underflow
109absx218 abs  0.001E-999       ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
110absx219 abs  0.0009E-999      ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
111absx220 abs  0.0001E-999      ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
112
113absx230 abs -1.00E-999        ->   1.00E-999
114absx231 abs -0.1E-999         ->   1E-1000   Subnormal
115absx232 abs -0.10E-999        ->   1.0E-1000 Subnormal
116absx233 abs -0.100E-999       ->   1.0E-1000 Subnormal Rounded
117absx234 abs -0.01E-999        ->   1E-1001   Subnormal
118-- next is rounded to Emin
119absx235 abs -0.999E-999       ->   1.00E-999 Inexact Rounded Subnormal Underflow
120absx236 abs -0.099E-999       ->   1.0E-1000 Inexact Rounded Subnormal Underflow
121absx237 abs -0.009E-999       ->   1E-1001   Inexact Rounded Subnormal Underflow
122absx238 abs -0.001E-999       ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
123absx239 abs -0.0009E-999      ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
124absx240 abs -0.0001E-999      ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
125
126-- long operand tests
127maxexponent: 999
128minexponent: -999
129precision: 9
130absx301 abs 12345678000  -> 1.23456780E+10 Rounded
131absx302 abs 1234567800   -> 1.23456780E+9 Rounded
132absx303 abs 1234567890   -> 1.23456789E+9 Rounded
133absx304 abs 1234567891   -> 1.23456789E+9 Inexact Rounded
134absx305 abs 12345678901  -> 1.23456789E+10 Inexact Rounded
135absx306 abs 1234567896   -> 1.23456790E+9 Inexact Rounded
136
137precision: 15
138absx321 abs 12345678000  -> 12345678000
139absx322 abs 1234567800   -> 1234567800
140absx323 abs 1234567890   -> 1234567890
141absx324 abs 1234567891   -> 1234567891
142absx325 abs 12345678901  -> 12345678901
143absx326 abs 1234567896   -> 1234567896
144
145
146-- Specials
147precision:   9
148
149-- specials
150absx520 abs 'Inf'    -> 'Infinity'
151absx521 abs '-Inf'   -> 'Infinity'
152absx522 abs   NaN    ->  NaN
153absx523 abs  sNaN    ->  NaN   Invalid_operation
154absx524 abs   NaN22  ->  NaN22
155absx525 abs  sNaN33  ->  NaN33 Invalid_operation
156absx526 abs  -NaN22  -> -NaN22
157absx527 abs -sNaN33  -> -NaN33 Invalid_operation
158
159-- Null tests
160absx900 abs  # -> NaN Invalid_operation
161
162