minmag.decTest 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. ------------------------------------------------------------------------
  2. -- minmag.decTest -- decimal minimum by magnitude --
  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. ------------------------------------------------------------------------
  20. version: 2.59
  21. -- we assume that base comparison is tested in compare.decTest, so
  22. -- these mainly cover special cases and rounding
  23. extended: 1
  24. precision: 9
  25. rounding: half_up
  26. maxExponent: 384
  27. minexponent: -383
  28. -- sanity checks
  29. mngx001 minmag -2 -2 -> -2
  30. mngx002 minmag -2 -1 -> -1
  31. mngx003 minmag -2 0 -> 0
  32. mngx004 minmag -2 1 -> 1
  33. mngx005 minmag -2 2 -> -2
  34. mngx006 minmag -1 -2 -> -1
  35. mngx007 minmag -1 -1 -> -1
  36. mngx008 minmag -1 0 -> 0
  37. mngx009 minmag -1 1 -> -1
  38. mngx010 minmag -1 2 -> -1
  39. mngx011 minmag 0 -2 -> 0
  40. mngx012 minmag 0 -1 -> 0
  41. mngx013 minmag 0 0 -> 0
  42. mngx014 minmag 0 1 -> 0
  43. mngx015 minmag 0 2 -> 0
  44. mngx016 minmag 1 -2 -> 1
  45. mngx017 minmag 1 -1 -> -1
  46. mngx018 minmag 1 0 -> 0
  47. mngx019 minmag 1 1 -> 1
  48. mngx020 minmag 1 2 -> 1
  49. mngx021 minmag 2 -2 -> -2
  50. mngx022 minmag 2 -1 -> -1
  51. mngx023 minmag 2 0 -> 0
  52. mngx025 minmag 2 1 -> 1
  53. mngx026 minmag 2 2 -> 2
  54. -- extended zeros
  55. mngx030 minmag 0 0 -> 0
  56. mngx031 minmag 0 -0 -> -0
  57. mngx032 minmag 0 -0.0 -> -0.0
  58. mngx033 minmag 0 0.0 -> 0.0
  59. mngx034 minmag -0 0 -> -0
  60. mngx035 minmag -0 -0 -> -0
  61. mngx036 minmag -0 -0.0 -> -0
  62. mngx037 minmag -0 0.0 -> -0
  63. mngx038 minmag 0.0 0 -> 0.0
  64. mngx039 minmag 0.0 -0 -> -0
  65. mngx040 minmag 0.0 -0.0 -> -0.0
  66. mngx041 minmag 0.0 0.0 -> 0.0
  67. mngx042 minmag -0.0 0 -> -0.0
  68. mngx043 minmag -0.0 -0 -> -0
  69. mngx044 minmag -0.0 -0.0 -> -0.0
  70. mngx045 minmag -0.0 0.0 -> -0.0
  71. mngx046 minmag 0E1 -0E1 -> -0E+1
  72. mngx047 minmag -0E1 0E2 -> -0E+1
  73. mngx048 minmag 0E2 0E1 -> 0E+1
  74. mngx049 minmag 0E1 0E2 -> 0E+1
  75. mngx050 minmag -0E3 -0E2 -> -0E+3
  76. mngx051 minmag -0E2 -0E3 -> -0E+3
  77. -- Specials
  78. precision: 9
  79. mngx090 minmag Inf -Inf -> -Infinity
  80. mngx091 minmag Inf -1000 -> -1000
  81. mngx092 minmag Inf -1 -> -1
  82. mngx093 minmag Inf -0 -> -0
  83. mngx094 minmag Inf 0 -> 0
  84. mngx095 minmag Inf 1 -> 1
  85. mngx096 minmag Inf 1000 -> 1000
  86. mngx097 minmag Inf Inf -> Infinity
  87. mngx098 minmag -1000 Inf -> -1000
  88. mngx099 minmag -Inf Inf -> -Infinity
  89. mngx100 minmag -1 Inf -> -1
  90. mngx101 minmag -0 Inf -> -0
  91. mngx102 minmag 0 Inf -> 0
  92. mngx103 minmag 1 Inf -> 1
  93. mngx104 minmag 1000 Inf -> 1000
  94. mngx105 minmag Inf Inf -> Infinity
  95. mngx120 minmag -Inf -Inf -> -Infinity
  96. mngx121 minmag -Inf -1000 -> -1000
  97. mngx122 minmag -Inf -1 -> -1
  98. mngx123 minmag -Inf -0 -> -0
  99. mngx124 minmag -Inf 0 -> 0
  100. mngx125 minmag -Inf 1 -> 1
  101. mngx126 minmag -Inf 1000 -> 1000
  102. mngx127 minmag -Inf Inf -> -Infinity
  103. mngx128 minmag -Inf -Inf -> -Infinity
  104. mngx129 minmag -1000 -Inf -> -1000
  105. mngx130 minmag -1 -Inf -> -1
  106. mngx131 minmag -0 -Inf -> -0
  107. mngx132 minmag 0 -Inf -> 0
  108. mngx133 minmag 1 -Inf -> 1
  109. mngx134 minmag 1000 -Inf -> 1000
  110. mngx135 minmag Inf -Inf -> -Infinity
  111. -- 2004.08.02 754r chooses number over NaN in mixed cases
  112. mngx141 minmag NaN -Inf -> -Infinity
  113. mngx142 minmag NaN -1000 -> -1000
  114. mngx143 minmag NaN -1 -> -1
  115. mngx144 minmag NaN -0 -> -0
  116. mngx145 minmag NaN 0 -> 0
  117. mngx146 minmag NaN 1 -> 1
  118. mngx147 minmag NaN 1000 -> 1000
  119. mngx148 minmag NaN Inf -> Infinity
  120. mngx149 minmag NaN NaN -> NaN
  121. mngx150 minmag -Inf NaN -> -Infinity
  122. mngx151 minmag -1000 NaN -> -1000
  123. mngx152 minmag -1 -NaN -> -1
  124. mngx153 minmag -0 NaN -> -0
  125. mngx154 minmag 0 -NaN -> 0
  126. mngx155 minmag 1 NaN -> 1
  127. mngx156 minmag 1000 NaN -> 1000
  128. mngx157 minmag Inf NaN -> Infinity
  129. mngx161 minmag sNaN -Inf -> NaN Invalid_operation
  130. mngx162 minmag sNaN -1000 -> NaN Invalid_operation
  131. mngx163 minmag sNaN -1 -> NaN Invalid_operation
  132. mngx164 minmag sNaN -0 -> NaN Invalid_operation
  133. mngx165 minmag -sNaN 0 -> -NaN Invalid_operation
  134. mngx166 minmag -sNaN 1 -> -NaN Invalid_operation
  135. mngx167 minmag sNaN 1000 -> NaN Invalid_operation
  136. mngx168 minmag sNaN NaN -> NaN Invalid_operation
  137. mngx169 minmag sNaN sNaN -> NaN Invalid_operation
  138. mngx170 minmag NaN sNaN -> NaN Invalid_operation
  139. mngx171 minmag -Inf sNaN -> NaN Invalid_operation
  140. mngx172 minmag -1000 sNaN -> NaN Invalid_operation
  141. mngx173 minmag -1 sNaN -> NaN Invalid_operation
  142. mngx174 minmag -0 sNaN -> NaN Invalid_operation
  143. mngx175 minmag 0 sNaN -> NaN Invalid_operation
  144. mngx176 minmag 1 sNaN -> NaN Invalid_operation
  145. mngx177 minmag 1000 sNaN -> NaN Invalid_operation
  146. mngx178 minmag Inf sNaN -> NaN Invalid_operation
  147. mngx179 minmag NaN sNaN -> NaN Invalid_operation
  148. -- propagating NaNs
  149. mngx181 minmag NaN9 -Inf -> -Infinity
  150. mngx182 minmag -NaN8 9990 -> 9990
  151. mngx183 minmag NaN71 Inf -> Infinity
  152. mngx184 minmag NaN1 NaN54 -> NaN1
  153. mngx185 minmag NaN22 -NaN53 -> NaN22
  154. mngx186 minmag -NaN3 NaN6 -> -NaN3
  155. mngx187 minmag -NaN44 NaN7 -> -NaN44
  156. mngx188 minmag -Inf NaN41 -> -Infinity
  157. mngx189 minmag -9999 -NaN33 -> -9999
  158. mngx190 minmag Inf NaN2 -> Infinity
  159. mngx191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
  160. mngx192 minmag sNaN98 -11 -> NaN98 Invalid_operation
  161. mngx193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
  162. mngx194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
  163. mngx195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
  164. mngx196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
  165. mngx197 minmag 088 sNaN91 -> NaN91 Invalid_operation
  166. mngx198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
  167. mngx199 minmag NaN sNaN86 -> NaN86 Invalid_operation
  168. -- rounding checks -- chosen is rounded, or not
  169. maxExponent: 999
  170. minexponent: -999
  171. precision: 9
  172. mngx201 minmag -12345678000 1 -> 1
  173. mngx202 minmag 1 -12345678000 -> 1
  174. mngx203 minmag -1234567800 1 -> 1
  175. mngx204 minmag 1 -1234567800 -> 1
  176. mngx205 minmag -1234567890 1 -> 1
  177. mngx206 minmag 1 -1234567890 -> 1
  178. mngx207 minmag -1234567891 1 -> 1
  179. mngx208 minmag 1 -1234567891 -> 1
  180. mngx209 minmag -12345678901 1 -> 1
  181. mngx210 minmag 1 -12345678901 -> 1
  182. mngx211 minmag -1234567896 1 -> 1
  183. mngx212 minmag 1 -1234567896 -> 1
  184. mngx213 minmag 1234567891 1 -> 1
  185. mngx214 minmag 1 1234567891 -> 1
  186. mngx215 minmag 12345678901 1 -> 1
  187. mngx216 minmag 1 12345678901 -> 1
  188. mngx217 minmag 1234567896 1 -> 1
  189. mngx218 minmag 1 1234567896 -> 1
  190. precision: 15
  191. mngx221 minmag -12345678000 1 -> 1
  192. mngx222 minmag 1 -12345678000 -> 1
  193. mngx223 minmag -1234567800 1 -> 1
  194. mngx224 minmag 1 -1234567800 -> 1
  195. mngx225 minmag -1234567890 1 -> 1
  196. mngx226 minmag 1 -1234567890 -> 1
  197. mngx227 minmag -1234567891 1 -> 1
  198. mngx228 minmag 1 -1234567891 -> 1
  199. mngx229 minmag -12345678901 1 -> 1
  200. mngx230 minmag 1 -12345678901 -> 1
  201. mngx231 minmag -1234567896 1 -> 1
  202. mngx232 minmag 1 -1234567896 -> 1
  203. mngx233 minmag 1234567891 1 -> 1
  204. mngx234 minmag 1 1234567891 -> 1
  205. mngx235 minmag 12345678901 1 -> 1
  206. mngx236 minmag 1 12345678901 -> 1
  207. mngx237 minmag 1234567896 1 -> 1
  208. mngx238 minmag 1 1234567896 -> 1
  209. -- from examples
  210. mngx280 minmag '3' '2' -> '2'
  211. mngx281 minmag '-10' '3' -> '3'
  212. mngx282 minmag '1.0' '1' -> '1.0'
  213. mngx283 minmag '1' '1.0' -> '1.0'
  214. mngx284 minmag '7' 'NaN' -> '7'
  215. -- overflow and underflow tests .. subnormal results [inputs] now allowed
  216. maxExponent: 999999999
  217. minexponent: -999999999
  218. mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
  219. mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
  220. mngx332 minmag -0.100 -9E-999999999 -> -9E-999999999
  221. mngx333 minmag -9E-999999999 -0.100 -> -9E-999999999
  222. mngx335 minmag +1.23456789012345E-0 -9E+999999999 -> 1.23456789012345
  223. mngx336 minmag -9E+999999999 1.23456789012345E-0 -> 1.23456789012345
  224. mngx337 minmag +0.100 -9E-999999999 -> -9E-999999999
  225. mngx338 minmag -9E-999999999 0.100 -> -9E-999999999
  226. mngx339 minmag -1e-599999999 -1e-400000001 -> -1E-599999999
  227. mngx340 minmag -1e-599999999 -1e-400000000 -> -1E-599999999
  228. mngx341 minmag -1e-600000000 -1e-400000000 -> -1E-600000000
  229. mngx342 minmag -9e-999999998 -0.01 -> -9E-999999998
  230. mngx343 minmag -9e-999999998 -0.1 -> -9E-999999998
  231. mngx344 minmag -0.01 -9e-999999998 -> -9E-999999998
  232. mngx345 minmag -1e599999999 -1e400000001 -> -1E+400000001
  233. mngx346 minmag -1e599999999 -1e400000000 -> -1E+400000000
  234. mngx347 minmag -1e600000000 -1e400000000 -> -1E+400000000
  235. mngx348 minmag -9e999999998 -100 -> -100
  236. mngx349 minmag -9e999999998 -10 -> -10
  237. mngx350 minmag -100 -9e999999998 -> -100
  238. -- signs
  239. mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
  240. mngx352 minmag -1e+777777777 +1e+411111111 -> 1E+411111111
  241. mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
  242. mngx354 minmag +1e+777777777 +1e+411111111 -> 1E+411111111
  243. mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
  244. mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
  245. mngx357 minmag +1e-777777777 -1e-411111111 -> 1E-777777777
  246. mngx358 minmag +1e-777777777 +1e-411111111 -> 1E-777777777
  247. -- expanded list from min/max 754r purple prose
  248. -- [explicit tests for exponent ordering]
  249. mngx401 minmag Inf 1.1 -> 1.1
  250. mngx402 minmag 1.1 1 -> 1
  251. mngx403 minmag 1 1.0 -> 1.0
  252. mngx404 minmag 1.0 0.1 -> 0.1
  253. mngx405 minmag 0.1 0.10 -> 0.10
  254. mngx406 minmag 0.10 0.100 -> 0.100
  255. mngx407 minmag 0.10 0 -> 0
  256. mngx408 minmag 0 0.0 -> 0.0
  257. mngx409 minmag 0.0 -0 -> -0
  258. mngx410 minmag 0.0 -0.0 -> -0.0
  259. mngx411 minmag 0.00 -0.0 -> -0.0
  260. mngx412 minmag 0.0 -0.00 -> -0.00
  261. mngx413 minmag 0 -0.0 -> -0.0
  262. mngx414 minmag 0 -0 -> -0
  263. mngx415 minmag -0.0 -0 -> -0
  264. mngx416 minmag -0 -0.100 -> -0
  265. mngx417 minmag -0.100 -0.10 -> -0.10
  266. mngx418 minmag -0.10 -0.1 -> -0.1
  267. mngx419 minmag -0.1 -1.0 -> -0.1
  268. mngx420 minmag -1.0 -1 -> -1
  269. mngx421 minmag -1 -1.1 -> -1
  270. mngx423 minmag -1.1 -Inf -> -1.1
  271. -- same with operands reversed
  272. mngx431 minmag 1.1 Inf -> 1.1
  273. mngx432 minmag 1 1.1 -> 1
  274. mngx433 minmag 1.0 1 -> 1.0
  275. mngx434 minmag 0.1 1.0 -> 0.1
  276. mngx435 minmag 0.10 0.1 -> 0.10
  277. mngx436 minmag 0.100 0.10 -> 0.100
  278. mngx437 minmag 0 0.10 -> 0
  279. mngx438 minmag 0.0 0 -> 0.0
  280. mngx439 minmag -0 0.0 -> -0
  281. mngx440 minmag -0.0 0.0 -> -0.0
  282. mngx441 minmag -0.0 0.00 -> -0.0
  283. mngx442 minmag -0.00 0.0 -> -0.00
  284. mngx443 minmag -0.0 0 -> -0.0
  285. mngx444 minmag -0 0 -> -0
  286. mngx445 minmag -0 -0.0 -> -0
  287. mngx446 minmag -0.100 -0 -> -0
  288. mngx447 minmag -0.10 -0.100 -> -0.10
  289. mngx448 minmag -0.1 -0.10 -> -0.1
  290. mngx449 minmag -1.0 -0.1 -> -0.1
  291. mngx450 minmag -1 -1.0 -> -1
  292. mngx451 minmag -1.1 -1 -> -1
  293. mngx453 minmag -Inf -1.1 -> -1.1
  294. -- largies
  295. mngx460 minmag 1000 1E+3 -> 1000
  296. mngx461 minmag 1E+3 1000 -> 1000
  297. mngx462 minmag 1000 -1E+3 -> -1E+3
  298. mngx463 minmag 1E+3 -1000 -> -1000
  299. mngx464 minmag -1000 1E+3 -> -1000
  300. mngx465 minmag -1E+3 1000 -> -1E+3
  301. mngx466 minmag -1000 -1E+3 -> -1E+3
  302. mngx467 minmag -1E+3 -1000 -> -1E+3
  303. -- rounding (results treated as though plus)
  304. maxexponent: 999999999
  305. minexponent: -999999999
  306. precision: 3
  307. mngx470 minmag 1 5 -> 1
  308. mngx471 minmag 10 50 -> 10
  309. mngx472 minmag 100 500 -> 100
  310. mngx473 minmag 1000 5000 -> 1.00E+3 Rounded
  311. mngx474 minmag 10000 50000 -> 1.00E+4 Rounded
  312. mngx475 minmag 6 50 -> 6
  313. mngx476 minmag 66 500 -> 66
  314. mngx477 minmag 666 5000 -> 666
  315. mngx478 minmag 6666 50000 -> 6.67E+3 Rounded Inexact
  316. mngx479 minmag 66666 500000 -> 6.67E+4 Rounded Inexact
  317. mngx480 minmag 33333 500000 -> 3.33E+4 Rounded Inexact
  318. mngx481 minmag 75401 1 -> 1
  319. mngx482 minmag 75402 10 -> 10
  320. mngx483 minmag 75403 100 -> 100
  321. mngx484 minmag 75404 1000 -> 1.00E+3 Rounded
  322. mngx485 minmag 75405 10000 -> 1.00E+4 Rounded
  323. mngx486 minmag 75406 6 -> 6
  324. mngx487 minmag 75407 66 -> 66
  325. mngx488 minmag 75408 666 -> 666
  326. mngx489 minmag 75409 6666 -> 6.67E+3 Rounded Inexact
  327. mngx490 minmag 75410 66666 -> 6.67E+4 Rounded Inexact
  328. mngx491 minmag 75411 33333 -> 3.33E+4 Rounded Inexact
  329. -- overflow tests
  330. maxexponent: 999999999
  331. minexponent: -999999999
  332. precision: 3
  333. mngx500 minmag 9.999E+999999999 0 -> 0
  334. mngx501 minmag -9.999E+999999999 0 -> 0
  335. -- subnormals and underflow
  336. precision: 3
  337. maxexponent: 999
  338. minexponent: -999
  339. mngx510 minmag 1.00E-999 0 -> 0
  340. mngx511 minmag 0.1E-999 0 -> 0
  341. mngx512 minmag 0.10E-999 0 -> 0
  342. mngx513 minmag 0.100E-999 0 -> 0
  343. mngx514 minmag 0.01E-999 0 -> 0
  344. mngx515 minmag 0.999E-999 0 -> 0
  345. mngx516 minmag 0.099E-999 0 -> 0
  346. mngx517 minmag 0.009E-999 0 -> 0
  347. mngx518 minmag 0.001E-999 0 -> 0
  348. mngx519 minmag 0.0009E-999 0 -> 0
  349. mngx520 minmag 0.0001E-999 0 -> 0
  350. mngx530 minmag -1.00E-999 0 -> 0
  351. mngx531 minmag -0.1E-999 0 -> 0
  352. mngx532 minmag -0.10E-999 0 -> 0
  353. mngx533 minmag -0.100E-999 0 -> 0
  354. mngx534 minmag -0.01E-999 0 -> 0
  355. mngx535 minmag -0.999E-999 0 -> 0
  356. mngx536 minmag -0.099E-999 0 -> 0
  357. mngx537 minmag -0.009E-999 0 -> 0
  358. mngx538 minmag -0.001E-999 0 -> 0
  359. mngx539 minmag -0.0009E-999 0 -> 0
  360. mngx540 minmag -0.0001E-999 0 -> 0
  361. -- Null tests
  362. mng900 minmag 10 # -> NaN Invalid_operation
  363. mng901 minmag # 10 -> NaN Invalid_operation