dsEncode.decTest 15 KB

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