PageRenderTime 29ms CodeModel.GetById 19ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Lib/test/decimaltestdata/dsEncode.decTest

http://unladen-swallow.googlecode.com/
Unknown | 372 lines | 337 code | 35 blank | 0 comment | 0 complexity | 2c6ccfe545ec3a50ba5af198694e3491 MD5 | raw file
  1------------------------------------------------------------------------
  2-- dsEncode.decTest -- decimal four-byte format testcases             --
  3-- Copyright (c) IBM Corporation, 2000, 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-- [Previously called decimal32.decTest]
 21version: 2.58
 22
 23-- This set of tests is for the four-byte concrete representation.
 24-- Its characteristics are:
 25--
 26--  1 bit  sign
 27--  5 bits combination field
 28--  6 bits exponent continuation
 29-- 20 bits coefficient continuation
 30--
 31-- Total exponent length 8 bits
 32-- Total coefficient length 24 bits (7 digits)
 33--
 34-- Elimit =  191 (maximum encoded exponent)
 35-- Emax   =   96 (largest exponent value)
 36-- Emin   =  -95 (smallest exponent value)
 37-- bias   =  101 (subtracted from encoded exponent) = -Etiny
 38
 39-- The testcases here have only exactly representable data on the
 40-- 'left-hand-side'; rounding from strings is tested in 'base'
 41-- testcase groups.
 42
 43extended:    1
 44clamp:       1
 45precision:   7
 46rounding:    half_up
 47maxExponent: 96
 48minExponent: -95
 49
 50-- General testcases
 51-- (mostly derived from the Strawman 4 document and examples)
 52decs001 apply   #A23003D0          -> -7.50
 53decs002 apply   -7.50              -> #A23003D0
 54-- derivative canonical plain strings
 55decs003 apply   #A26003D0         -> -7.50E+3
 56decs004 apply   -7.50E+3          -> #A26003D0
 57decs005 apply   #A25003D0         -> -750
 58decs006 apply   -750              -> #A25003D0
 59decs007 apply   #A24003D0         -> -75.0
 60decs008 apply   -75.0             -> #A24003D0
 61decs009 apply   #A22003D0         -> -0.750
 62decs010 apply   -0.750            -> #A22003D0
 63decs011 apply   #A21003D0         -> -0.0750
 64decs012 apply   -0.0750           -> #A21003D0
 65decs013 apply   #A1f003D0         -> -0.000750
 66decs014 apply   -0.000750         -> #A1f003D0
 67decs015 apply   #A1d003D0         -> -0.00000750
 68decs016 apply   -0.00000750       -> #A1d003D0
 69decs017 apply   #A1c003D0         -> -7.50E-7
 70decs018 apply   -7.50E-7          -> #A1c003D0
 71
 72-- Normality
 73decs020 apply   1234567            -> #2654d2e7
 74decs021 apply  -1234567            -> #a654d2e7
 75decs022 apply   1111111            -> #26524491
 76
 77-- Nmax and similar
 78decs031 apply   9.999999E+96            -> #77f3fcff
 79decs032 apply   #77f3fcff               -> 9.999999E+96
 80decs033 apply   1.234567E+96            -> #47f4d2e7
 81decs034 apply   #47f4d2e7               -> 1.234567E+96
 82-- fold-downs (more below)
 83decs035 apply   1.23E+96                -> #47f4c000 Clamped
 84decs036 apply   #47f4c000               -> 1.230000E+96
 85decs037 apply   1E+96                   -> #47f00000 Clamped
 86decs038 apply   #47f00000               -> 1.000000E+96
 87
 88decs051 apply   12345                   -> #225049c5
 89decs052 apply   #225049c5               -> 12345
 90decs053 apply   1234                    -> #22500534
 91decs054 apply   #22500534               -> 1234
 92decs055 apply   123                     -> #225000a3
 93decs056 apply   #225000a3               -> 123
 94decs057 apply   12                      -> #22500012
 95decs058 apply   #22500012               -> 12
 96decs059 apply   1                       -> #22500001
 97decs060 apply   #22500001               -> 1
 98decs061 apply   1.23                    -> #223000a3
 99decs062 apply   #223000a3               -> 1.23
100decs063 apply   123.45                  -> #223049c5
101decs064 apply   #223049c5               -> 123.45
102
103-- Nmin and below
104decs071 apply   1E-95                   -> #00600001
105decs072 apply   #00600001               -> 1E-95
106decs073 apply   1.000000E-95            -> #04000000
107decs074 apply   #04000000               -> 1.000000E-95
108decs075 apply   1.000001E-95            -> #04000001
109decs076 apply   #04000001               -> 1.000001E-95
110
111decs077 apply   0.100000E-95            -> #00020000     Subnormal
112decs07x apply   1.00000E-96             -> 1.00000E-96   Subnormal
113decs078 apply   #00020000               -> 1.00000E-96   Subnormal
114decs079 apply   0.000010E-95            -> #00000010     Subnormal
115decs080 apply   #00000010               -> 1.0E-100      Subnormal
116decs081 apply   0.000001E-95            -> #00000001     Subnormal
117decs082 apply   #00000001               -> 1E-101        Subnormal
118decs083 apply   1e-101                  -> #00000001     Subnormal
119decs084 apply   #00000001               -> 1E-101        Subnormal
120decs08x apply   1e-101                  -> 1E-101        Subnormal
121
122-- underflows cannot be tested; just check edge case
123decs090 apply   1e-101                  -> #00000001  Subnormal
124
125-- same again, negatives --
126
127-- Nmax and similar
128decs122 apply  -9.999999E+96            -> #f7f3fcff
129decs123 apply   #f7f3fcff               -> -9.999999E+96
130decs124 apply  -1.234567E+96            -> #c7f4d2e7
131decs125 apply   #c7f4d2e7               -> -1.234567E+96
132-- fold-downs (more below)
133decs130 apply  -1.23E+96                -> #c7f4c000 Clamped
134decs131 apply   #c7f4c000               -> -1.230000E+96
135decs132 apply  -1E+96                   -> #c7f00000 Clamped
136decs133 apply   #c7f00000               -> -1.000000E+96
137
138decs151 apply  -12345                   -> #a25049c5
139decs152 apply   #a25049c5               -> -12345
140decs153 apply  -1234                    -> #a2500534
141decs154 apply   #a2500534               -> -1234
142decs155 apply  -123                     -> #a25000a3
143decs156 apply   #a25000a3               -> -123
144decs157 apply  -12                      -> #a2500012
145decs158 apply   #a2500012               -> -12
146decs159 apply  -1                       -> #a2500001
147decs160 apply   #a2500001               -> -1
148decs161 apply  -1.23                    -> #a23000a3
149decs162 apply   #a23000a3               -> -1.23
150decs163 apply  -123.45                  -> #a23049c5
151decs164 apply   #a23049c5               -> -123.45
152
153-- Nmin and below
154decs171 apply  -1E-95                   -> #80600001
155decs172 apply   #80600001               -> -1E-95
156decs173 apply  -1.000000E-95            -> #84000000
157decs174 apply   #84000000               -> -1.000000E-95
158decs175 apply  -1.000001E-95            -> #84000001
159decs176 apply   #84000001               -> -1.000001E-95
160
161decs177 apply  -0.100000E-95            -> #80020000     Subnormal
162decs178 apply   #80020000               -> -1.00000E-96  Subnormal
163decs179 apply  -0.000010E-95            -> #80000010     Subnormal
164decs180 apply   #80000010               -> -1.0E-100     Subnormal
165decs181 apply  -0.000001E-95            -> #80000001     Subnormal
166decs182 apply   #80000001               -> -1E-101       Subnormal
167decs183 apply  -1e-101                  -> #80000001     Subnormal
168decs184 apply   #80000001               -> -1E-101       Subnormal
169
170-- underflow edge case
171decs190 apply  -1e-101                  -> #80000001  Subnormal
172
173-- zeros
174decs400 apply   0E-400                  -> #00000000  Clamped
175decs401 apply   0E-101                  -> #00000000
176decs402 apply   #00000000               -> 0E-101
177decs403 apply   0.000000E-95            -> #00000000
178decs404 apply   #00000000               -> 0E-101
179decs405 apply   0E-2                    -> #22300000
180decs406 apply   #22300000               -> 0.00
181decs407 apply   0                       -> #22500000
182decs408 apply   #22500000               -> 0
183decs409 apply   0E+3                    -> #22800000
184decs410 apply   #22800000               -> 0E+3
185decs411 apply   0E+90                   -> #43f00000
186decs412 apply   #43f00000               -> 0E+90
187-- clamped zeros...
188decs413 apply   0E+91                   -> #43f00000  Clamped
189decs414 apply   #43f00000               -> 0E+90
190decs415 apply   0E+96                   -> #43f00000  Clamped
191decs416 apply   #43f00000               -> 0E+90
192decs417 apply   0E+400                  -> #43f00000  Clamped
193decs418 apply   #43f00000               -> 0E+90
194
195-- negative zeros
196decs420 apply   -0E-400                 -> #80000000  Clamped
197decs421 apply   -0E-101                 -> #80000000
198decs422 apply   #80000000               -> -0E-101
199decs423 apply   -0.000000E-95           -> #80000000
200decs424 apply   #80000000               -> -0E-101
201decs425 apply   -0E-2                   -> #a2300000
202decs426 apply   #a2300000               -> -0.00
203decs427 apply   -0                      -> #a2500000
204decs428 apply   #a2500000               -> -0
205decs429 apply   -0E+3                   -> #a2800000
206decs430 apply   #a2800000               -> -0E+3
207decs431 apply   -0E+90                  -> #c3f00000
208decs432 apply   #c3f00000               -> -0E+90
209-- clamped zeros...
210decs433 apply   -0E+91                  -> #c3f00000  Clamped
211decs434 apply   #c3f00000               -> -0E+90
212decs435 apply   -0E+96                  -> #c3f00000  Clamped
213decs436 apply   #c3f00000               -> -0E+90
214decs437 apply   -0E+400                 -> #c3f00000  Clamped
215decs438 apply   #c3f00000               -> -0E+90
216
217-- Specials
218decs500 apply   Infinity  -> #78000000
219decs501 apply   #78787878 -> #78000000
220decs502 apply   #78000000 -> Infinity
221decs503 apply   #79797979 -> #78000000
222decs504 apply   #79000000 -> Infinity
223decs505 apply   #7a7a7a7a -> #78000000
224decs506 apply   #7a000000 -> Infinity
225decs507 apply   #7b7b7b7b -> #78000000
226decs508 apply   #7b000000 -> Infinity
227decs509 apply   #7c7c7c7c -> #7c0c7c7c
228
229decs510 apply   NaN       -> #7c000000
230decs511 apply   #7c000000 -> NaN
231decs512 apply   #7d7d7d7d -> #7c0d7d7d
232decs513 apply   #7d000000 -> NaN
233decs514 apply   #7e7e7e7e -> #7e0e7c7e
234decs515 apply   #7e000000 -> sNaN
235decs516 apply   #7f7f7f7f -> #7e0f7c7f
236decs517 apply   #7f000000 -> sNaN
237decs518 apply   #7fffffff -> sNaN999999
238decs519 apply   #7fffffff -> #7e03fcff
239
240decs520 apply   -Infinity -> #f8000000
241decs521 apply   #f8787878 -> #f8000000
242decs522 apply   #f8000000 -> -Infinity
243decs523 apply   #f9797979 -> #f8000000
244decs524 apply   #f9000000 -> -Infinity
245decs525 apply   #fa7a7a7a -> #f8000000
246decs526 apply   #fa000000 -> -Infinity
247decs527 apply   #fb7b7b7b -> #f8000000
248decs528 apply   #fb000000 -> -Infinity
249
250decs529 apply   -NaN      -> #fc000000
251decs530 apply   #fc7c7c7c -> #fc0c7c7c
252decs531 apply   #fc000000 -> -NaN
253decs532 apply   #fd7d7d7d -> #fc0d7d7d
254decs533 apply   #fd000000 -> -NaN
255decs534 apply   #fe7e7e7e -> #fe0e7c7e
256decs535 apply   #fe000000 -> -sNaN
257decs536 apply   #ff7f7f7f -> #fe0f7c7f
258decs537 apply   #ff000000 -> -sNaN
259decs538 apply   #ffffffff -> -sNaN999999
260decs539 apply   #ffffffff -> #fe03fcff
261
262-- diagnostic NaNs
263decs540 apply   NaN       -> #7c000000
264decs541 apply   NaN0      -> #7c000000
265decs542 apply   NaN1      -> #7c000001
266decs543 apply   NaN12     -> #7c000012
267decs544 apply   NaN79     -> #7c000079
268decs545 apply   NaN12345   -> #7c0049c5
269decs546 apply   NaN123456  -> #7c028e56
270decs547 apply   NaN799799  -> #7c0f7fdf
271decs548 apply   NaN999999  -> #7c03fcff
272
273
274-- fold-down full sequence
275decs601 apply   1E+96                   -> #47f00000 Clamped
276decs602 apply   #47f00000               -> 1.000000E+96
277decs603 apply   1E+95                   -> #43f20000 Clamped
278decs604 apply   #43f20000               -> 1.00000E+95
279decs605 apply   1E+94                   -> #43f04000 Clamped
280decs606 apply   #43f04000               -> 1.0000E+94
281decs607 apply   1E+93                   -> #43f00400 Clamped
282decs608 apply   #43f00400               -> 1.000E+93
283decs609 apply   1E+92                   -> #43f00080 Clamped
284decs610 apply   #43f00080               -> 1.00E+92
285decs611 apply   1E+91                   -> #43f00010 Clamped
286decs612 apply   #43f00010               -> 1.0E+91
287decs613 apply   1E+90                   -> #43f00001
288decs614 apply   #43f00001               -> 1E+90
289
290
291-- Selected DPD codes
292decs700 apply   #22500000       -> 0
293decs701 apply   #22500009       -> 9
294decs702 apply   #22500010       -> 10
295decs703 apply   #22500019       -> 19
296decs704 apply   #22500020       -> 20
297decs705 apply   #22500029       -> 29
298decs706 apply   #22500030       -> 30
299decs707 apply   #22500039       -> 39
300decs708 apply   #22500040       -> 40
301decs709 apply   #22500049       -> 49
302decs710 apply   #22500050       -> 50
303decs711 apply   #22500059       -> 59
304decs712 apply   #22500060       -> 60
305decs713 apply   #22500069       -> 69
306decs714 apply   #22500070       -> 70
307decs715 apply   #22500071       -> 71
308decs716 apply   #22500072       -> 72
309decs717 apply   #22500073       -> 73
310decs718 apply   #22500074       -> 74
311decs719 apply   #22500075       -> 75
312decs720 apply   #22500076       -> 76
313decs721 apply   #22500077       -> 77
314decs722 apply   #22500078       -> 78
315decs723 apply   #22500079       -> 79
316
317decs730 apply   #2250029e       -> 994
318decs731 apply   #2250029f       -> 995
319decs732 apply   #225002a0       -> 520
320decs733 apply   #225002a1       -> 521
321
322-- DPD: one of each of the huffman groups
323decs740 apply   #225003f7       -> 777
324decs741 apply   #225003f8       -> 778
325decs742 apply   #225003eb       -> 787
326decs743 apply   #2250037d       -> 877
327decs744 apply   #2250039f       -> 997
328decs745 apply   #225003bf       -> 979
329decs746 apply   #225003df       -> 799
330decs747 apply   #2250006e       -> 888
331
332
333-- DPD all-highs cases (includes the 24 redundant codes)
334decs750 apply   #2250006e       -> 888
335decs751 apply   #2250016e       -> 888
336decs752 apply   #2250026e       -> 888
337decs753 apply   #2250036e       -> 888
338decs754 apply   #2250006f       -> 889
339decs755 apply   #2250016f       -> 889
340decs756 apply   #2250026f       -> 889
341decs757 apply   #2250036f       -> 889
342
343decs760 apply   #2250007e       -> 898
344decs761 apply   #2250017e       -> 898
345decs762 apply   #2250027e       -> 898
346decs763 apply   #2250037e       -> 898
347decs764 apply   #2250007f       -> 899
348decs765 apply   #2250017f       -> 899
349decs766 apply   #2250027f       -> 899
350decs767 apply   #2250037f       -> 899
351
352decs770 apply   #225000ee       -> 988
353decs771 apply   #225001ee       -> 988
354decs772 apply   #225002ee       -> 988
355decs773 apply   #225003ee       -> 988
356decs774 apply   #225000ef       -> 989
357decs775 apply   #225001ef       -> 989
358decs776 apply   #225002ef       -> 989
359decs777 apply   #225003ef       -> 989
360
361decs780 apply   #225000fe       -> 998
362decs781 apply   #225001fe       -> 998
363decs782 apply   #225002fe       -> 998
364decs783 apply   #225003fe       -> 998
365decs784 apply   #225000ff       -> 999
366decs785 apply   #225001ff       -> 999
367decs786 apply   #225002ff       -> 999
368decs787 apply   #225003ff       -> 999
369
370-- narrowing case
371decs790 apply 2.00E-99 -> #00000100 Subnormal
372decs791 apply #00000100 -> 2.00E-99 Subnormal