PageRenderTime 34ms CodeModel.GetById 19ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/Lib/test/decimaltestdata/reduce.decTest

http://unladen-swallow.googlecode.com/
Unknown | 234 lines | 216 code | 18 blank | 0 comment | 0 complexity | 698b3cc5dd3677023bca8e52a3f63408 MD5 | raw file
  1------------------------------------------------------------------------
  2-- reduce.decTest -- remove trailing zeros                            --
  3-- Copyright (c) IBM Corporation, 2003, 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------------------------------------------------------------------------
 20-- [This used to be called normalize.]
 21
 22version: 2.58
 23
 24extended:    1
 25precision:   9
 26rounding:    half_up
 27maxExponent: 999
 28minexponent: -999
 29
 30redx001 reduce '1'      -> '1'
 31redx002 reduce '-1'     -> '-1'
 32redx003 reduce '1.00'   -> '1'
 33redx004 reduce '-1.00'  -> '-1'
 34redx005 reduce '0'      -> '0'
 35redx006 reduce '0.00'   -> '0'
 36redx007 reduce '00.0'   -> '0'
 37redx008 reduce '00.00'  -> '0'
 38redx009 reduce '00'     -> '0'
 39redx010 reduce '0E+1'   -> '0'
 40redx011 reduce '0E+5'   -> '0'
 41
 42redx012 reduce '-2'     -> '-2'
 43redx013 reduce '2'      -> '2'
 44redx014 reduce '-2.00'  -> '-2'
 45redx015 reduce '2.00'   -> '2'
 46redx016 reduce '-0'     -> '-0'
 47redx017 reduce '-0.00'  -> '-0'
 48redx018 reduce '-00.0'  -> '-0'
 49redx019 reduce '-00.00' -> '-0'
 50redx020 reduce '-00'    -> '-0'
 51redx021 reduce '-0E+5'   -> '-0'
 52redx022 reduce '-0E+1'  -> '-0'
 53
 54redx030 reduce '+0.1'            -> '0.1'
 55redx031 reduce '-0.1'            -> '-0.1'
 56redx032 reduce '+0.01'           -> '0.01'
 57redx033 reduce '-0.01'           -> '-0.01'
 58redx034 reduce '+0.001'          -> '0.001'
 59redx035 reduce '-0.001'          -> '-0.001'
 60redx036 reduce '+0.000001'       -> '0.000001'
 61redx037 reduce '-0.000001'       -> '-0.000001'
 62redx038 reduce '+0.000000000001' -> '1E-12'
 63redx039 reduce '-0.000000000001' -> '-1E-12'
 64
 65redx041 reduce 1.1        -> 1.1
 66redx042 reduce 1.10       -> 1.1
 67redx043 reduce 1.100      -> 1.1
 68redx044 reduce 1.110      -> 1.11
 69redx045 reduce -1.1       -> -1.1
 70redx046 reduce -1.10      -> -1.1
 71redx047 reduce -1.100     -> -1.1
 72redx048 reduce -1.110     -> -1.11
 73redx049 reduce 9.9        -> 9.9
 74redx050 reduce 9.90       -> 9.9
 75redx051 reduce 9.900      -> 9.9
 76redx052 reduce 9.990      -> 9.99
 77redx053 reduce -9.9       -> -9.9
 78redx054 reduce -9.90      -> -9.9
 79redx055 reduce -9.900     -> -9.9
 80redx056 reduce -9.990     -> -9.99
 81
 82-- some trailing fractional zeros with zeros in units
 83redx060 reduce  10.0        -> 1E+1
 84redx061 reduce  10.00       -> 1E+1
 85redx062 reduce  100.0       -> 1E+2
 86redx063 reduce  100.00      -> 1E+2
 87redx064 reduce  1.1000E+3   -> 1.1E+3
 88redx065 reduce  1.10000E+3  -> 1.1E+3
 89redx066 reduce -10.0        -> -1E+1
 90redx067 reduce -10.00       -> -1E+1
 91redx068 reduce -100.0       -> -1E+2
 92redx069 reduce -100.00      -> -1E+2
 93redx070 reduce -1.1000E+3   -> -1.1E+3
 94redx071 reduce -1.10000E+3  -> -1.1E+3
 95
 96-- some insignificant trailing zeros with positive exponent
 97redx080 reduce  10E+1       -> 1E+2
 98redx081 reduce  100E+1      -> 1E+3
 99redx082 reduce  1.0E+2      -> 1E+2
100redx083 reduce  1.0E+3      -> 1E+3
101redx084 reduce  1.1E+3      -> 1.1E+3
102redx085 reduce  1.00E+3     -> 1E+3
103redx086 reduce  1.10E+3     -> 1.1E+3
104redx087 reduce -10E+1       -> -1E+2
105redx088 reduce -100E+1      -> -1E+3
106redx089 reduce -1.0E+2      -> -1E+2
107redx090 reduce -1.0E+3      -> -1E+3
108redx091 reduce -1.1E+3      -> -1.1E+3
109redx092 reduce -1.00E+3     -> -1E+3
110redx093 reduce -1.10E+3     -> -1.1E+3
111
112-- some significant trailing zeros, were we to be trimming
113redx100 reduce  11          -> 11
114redx101 reduce  10          -> 1E+1
115redx102 reduce  10.         -> 1E+1
116redx103 reduce  1.1E+1      -> 11
117redx104 reduce  1.0E+1      -> 1E+1
118redx105 reduce  1.10E+2     -> 1.1E+2
119redx106 reduce  1.00E+2     -> 1E+2
120redx107 reduce  1.100E+3    -> 1.1E+3
121redx108 reduce  1.000E+3    -> 1E+3
122redx109 reduce  1.000000E+6 -> 1E+6
123redx110 reduce -11          -> -11
124redx111 reduce -10          -> -1E+1
125redx112 reduce -10.         -> -1E+1
126redx113 reduce -1.1E+1      -> -11
127redx114 reduce -1.0E+1      -> -1E+1
128redx115 reduce -1.10E+2     -> -1.1E+2
129redx116 reduce -1.00E+2     -> -1E+2
130redx117 reduce -1.100E+3    -> -1.1E+3
131redx118 reduce -1.000E+3    -> -1E+3
132redx119 reduce -1.00000E+5  -> -1E+5
133redx120 reduce -1.000000E+6 -> -1E+6
134redx121 reduce -10.00000E+6 -> -1E+7
135redx122 reduce -100.0000E+6 -> -1E+8
136redx123 reduce -1000.000E+6 -> -1E+9
137redx124 reduce -10000.00E+6 -> -1E+10
138redx125 reduce -100000.0E+6 -> -1E+11
139redx126 reduce -1000000.E+6 -> -1E+12
140
141-- examples from decArith
142redx140 reduce '2.1'     ->  '2.1'
143redx141 reduce '-2.0'    ->  '-2'
144redx142 reduce '1.200'   ->  '1.2'
145redx143 reduce '-120'    ->  '-1.2E+2'
146redx144 reduce '120.00'  ->  '1.2E+2'
147redx145 reduce '0.00'    ->  '0'
148
149-- overflow tests
150maxexponent: 999999999
151minexponent: -999999999
152precision: 3
153redx160 reduce 9.999E+999999999  ->  Infinity Inexact Overflow Rounded
154redx161 reduce -9.999E+999999999 -> -Infinity Inexact Overflow Rounded
155
156-- subnormals and underflow
157precision: 3
158maxexponent: 999
159minexponent: -999
160redx210 reduce  1.00E-999        ->   1E-999
161redx211 reduce  0.1E-999         ->   1E-1000   Subnormal
162redx212 reduce  0.10E-999        ->   1E-1000   Subnormal
163redx213 reduce  0.100E-999       ->   1E-1000   Subnormal Rounded
164redx214 reduce  0.01E-999        ->   1E-1001   Subnormal
165-- next is rounded to Emin
166redx215 reduce  0.999E-999       ->   1E-999    Inexact Rounded Subnormal Underflow
167redx216 reduce  0.099E-999       ->   1E-1000   Inexact Rounded Subnormal Underflow
168redx217 reduce  0.009E-999       ->   1E-1001   Inexact Rounded Subnormal Underflow
169redx218 reduce  0.001E-999       ->   0         Inexact Rounded Subnormal Underflow Clamped
170redx219 reduce  0.0009E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped
171redx220 reduce  0.0001E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped
172
173redx230 reduce -1.00E-999        ->  -1E-999
174redx231 reduce -0.1E-999         ->  -1E-1000   Subnormal
175redx232 reduce -0.10E-999        ->  -1E-1000   Subnormal
176redx233 reduce -0.100E-999       ->  -1E-1000   Subnormal Rounded
177redx234 reduce -0.01E-999        ->  -1E-1001   Subnormal
178-- next is rounded to Emin
179redx235 reduce -0.999E-999       ->  -1E-999    Inexact Rounded Subnormal Underflow
180redx236 reduce -0.099E-999       ->  -1E-1000   Inexact Rounded Subnormal Underflow
181redx237 reduce -0.009E-999       ->  -1E-1001   Inexact Rounded Subnormal Underflow
182redx238 reduce -0.001E-999       ->  -0         Inexact Rounded Subnormal Underflow Clamped
183redx239 reduce -0.0009E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped
184redx240 reduce -0.0001E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped
185
186-- more reshaping
187precision: 9
188redx260 reduce '56260E-10'   -> '0.000005626'
189redx261 reduce '56260E-5'    -> '0.5626'
190redx262 reduce '56260E-2'    -> '562.6'
191redx263 reduce '56260E-1'    -> '5626'
192redx265 reduce '56260E-0'    -> '5.626E+4'
193redx266 reduce '56260E+0'    -> '5.626E+4'
194redx267 reduce '56260E+1'    -> '5.626E+5'
195redx268 reduce '56260E+2'    -> '5.626E+6'
196redx269 reduce '56260E+3'    -> '5.626E+7'
197redx270 reduce '56260E+4'    -> '5.626E+8'
198redx271 reduce '56260E+5'    -> '5.626E+9'
199redx272 reduce '56260E+6'    -> '5.626E+10'
200redx280 reduce '-56260E-10'  -> '-0.000005626'
201redx281 reduce '-56260E-5'   -> '-0.5626'
202redx282 reduce '-56260E-2'   -> '-562.6'
203redx283 reduce '-56260E-1'   -> '-5626'
204redx285 reduce '-56260E-0'   -> '-5.626E+4'
205redx286 reduce '-56260E+0'   -> '-5.626E+4'
206redx287 reduce '-56260E+1'   -> '-5.626E+5'
207redx288 reduce '-56260E+2'   -> '-5.626E+6'
208redx289 reduce '-56260E+3'   -> '-5.626E+7'
209redx290 reduce '-56260E+4'   -> '-5.626E+8'
210redx291 reduce '-56260E+5'   -> '-5.626E+9'
211redx292 reduce '-56260E+6'   -> '-5.626E+10'
212
213-- FL test
214precision: 40
215redx295 reduce 9892345673.0123456780000000000 -> 9892345673.012345678
216
217-- specials
218redx820 reduce 'Inf'    -> 'Infinity'
219redx821 reduce '-Inf'   -> '-Infinity'
220redx822 reduce   NaN    ->  NaN
221redx823 reduce  sNaN    ->  NaN    Invalid_operation
222redx824 reduce   NaN101 ->  NaN101
223redx825 reduce  sNaN010 ->  NaN10  Invalid_operation
224redx827 reduce  -NaN    -> -NaN
225redx828 reduce -sNaN    -> -NaN    Invalid_operation
226redx829 reduce  -NaN101 -> -NaN101
227redx830 reduce -sNaN010 -> -NaN10  Invalid_operation
228
229-- payload decapitate
230precision: 5
231redx62100 reduce  sNaN1234567890 -> NaN67890  Invalid_operation
232
233-- Null test
234redx900 reduce  # -> NaN Invalid_operation