tointegral.decTest 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. ------------------------------------------------------------------------
  2. -- tointegral.decTest -- round decimal to integral value --
  3. -- Copyright (c) IBM Corporation, 2001, 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. -- This set of tests tests the extended specification 'round-to-integral
  22. -- value' operation (from IEEE 854, later modified in 754r).
  23. -- All non-zero results are defined as being those from either copy or
  24. -- quantize, so those are assumed to have been tested.
  25. -- Note that 754r requires that Inexact not be set, and we similarly
  26. -- assume Rounded is not set.
  27. extended: 1
  28. precision: 9
  29. rounding: half_up
  30. maxExponent: 999
  31. minExponent: -999
  32. intx001 tointegral 0 -> 0
  33. intx002 tointegral 0.0 -> 0
  34. intx003 tointegral 0.1 -> 0
  35. intx004 tointegral 0.2 -> 0
  36. intx005 tointegral 0.3 -> 0
  37. intx006 tointegral 0.4 -> 0
  38. intx007 tointegral 0.5 -> 1
  39. intx008 tointegral 0.6 -> 1
  40. intx009 tointegral 0.7 -> 1
  41. intx010 tointegral 0.8 -> 1
  42. intx011 tointegral 0.9 -> 1
  43. intx012 tointegral 1 -> 1
  44. intx013 tointegral 1.0 -> 1
  45. intx014 tointegral 1.1 -> 1
  46. intx015 tointegral 1.2 -> 1
  47. intx016 tointegral 1.3 -> 1
  48. intx017 tointegral 1.4 -> 1
  49. intx018 tointegral 1.5 -> 2
  50. intx019 tointegral 1.6 -> 2
  51. intx020 tointegral 1.7 -> 2
  52. intx021 tointegral 1.8 -> 2
  53. intx022 tointegral 1.9 -> 2
  54. -- negatives
  55. intx031 tointegral -0 -> -0
  56. intx032 tointegral -0.0 -> -0
  57. intx033 tointegral -0.1 -> -0
  58. intx034 tointegral -0.2 -> -0
  59. intx035 tointegral -0.3 -> -0
  60. intx036 tointegral -0.4 -> -0
  61. intx037 tointegral -0.5 -> -1
  62. intx038 tointegral -0.6 -> -1
  63. intx039 tointegral -0.7 -> -1
  64. intx040 tointegral -0.8 -> -1
  65. intx041 tointegral -0.9 -> -1
  66. intx042 tointegral -1 -> -1
  67. intx043 tointegral -1.0 -> -1
  68. intx044 tointegral -1.1 -> -1
  69. intx045 tointegral -1.2 -> -1
  70. intx046 tointegral -1.3 -> -1
  71. intx047 tointegral -1.4 -> -1
  72. intx048 tointegral -1.5 -> -2
  73. intx049 tointegral -1.6 -> -2
  74. intx050 tointegral -1.7 -> -2
  75. intx051 tointegral -1.8 -> -2
  76. intx052 tointegral -1.9 -> -2
  77. -- next two would be NaN using quantize(x, 0)
  78. intx053 tointegral 10E+30 -> 1.0E+31
  79. intx054 tointegral -10E+30 -> -1.0E+31
  80. -- numbers around precision
  81. precision: 9
  82. intx060 tointegral '56267E-10' -> '0'
  83. intx061 tointegral '56267E-5' -> '1'
  84. intx062 tointegral '56267E-2' -> '563'
  85. intx063 tointegral '56267E-1' -> '5627'
  86. intx065 tointegral '56267E-0' -> '56267'
  87. intx066 tointegral '56267E+0' -> '56267'
  88. intx067 tointegral '56267E+1' -> '5.6267E+5'
  89. intx068 tointegral '56267E+2' -> '5.6267E+6'
  90. intx069 tointegral '56267E+3' -> '5.6267E+7'
  91. intx070 tointegral '56267E+4' -> '5.6267E+8'
  92. intx071 tointegral '56267E+5' -> '5.6267E+9'
  93. intx072 tointegral '56267E+6' -> '5.6267E+10'
  94. intx073 tointegral '1.23E+96' -> '1.23E+96'
  95. intx074 tointegral '1.23E+384' -> '1.23E+384'
  96. intx075 tointegral '1.23E+999' -> '1.23E+999'
  97. intx080 tointegral '-56267E-10' -> '-0'
  98. intx081 tointegral '-56267E-5' -> '-1'
  99. intx082 tointegral '-56267E-2' -> '-563'
  100. intx083 tointegral '-56267E-1' -> '-5627'
  101. intx085 tointegral '-56267E-0' -> '-56267'
  102. intx086 tointegral '-56267E+0' -> '-56267'
  103. intx087 tointegral '-56267E+1' -> '-5.6267E+5'
  104. intx088 tointegral '-56267E+2' -> '-5.6267E+6'
  105. intx089 tointegral '-56267E+3' -> '-5.6267E+7'
  106. intx090 tointegral '-56267E+4' -> '-5.6267E+8'
  107. intx091 tointegral '-56267E+5' -> '-5.6267E+9'
  108. intx092 tointegral '-56267E+6' -> '-5.6267E+10'
  109. intx093 tointegral '-1.23E+96' -> '-1.23E+96'
  110. intx094 tointegral '-1.23E+384' -> '-1.23E+384'
  111. intx095 tointegral '-1.23E+999' -> '-1.23E+999'
  112. -- subnormal inputs
  113. intx100 tointegral 1E-999 -> 0
  114. intx101 tointegral 0.1E-999 -> 0
  115. intx102 tointegral 0.01E-999 -> 0
  116. intx103 tointegral 0E-999 -> 0
  117. -- specials and zeros
  118. intx120 tointegral 'Inf' -> Infinity
  119. intx121 tointegral '-Inf' -> -Infinity
  120. intx122 tointegral NaN -> NaN
  121. intx123 tointegral sNaN -> NaN Invalid_operation
  122. intx124 tointegral 0 -> 0
  123. intx125 tointegral -0 -> -0
  124. intx126 tointegral 0.000 -> 0
  125. intx127 tointegral 0.00 -> 0
  126. intx128 tointegral 0.0 -> 0
  127. intx129 tointegral 0 -> 0
  128. intx130 tointegral 0E-3 -> 0
  129. intx131 tointegral 0E-2 -> 0
  130. intx132 tointegral 0E-1 -> 0
  131. intx133 tointegral 0E-0 -> 0
  132. intx134 tointegral 0E+1 -> 0E+1
  133. intx135 tointegral 0E+2 -> 0E+2
  134. intx136 tointegral 0E+3 -> 0E+3
  135. intx137 tointegral 0E+4 -> 0E+4
  136. intx138 tointegral 0E+5 -> 0E+5
  137. intx139 tointegral -0.000 -> -0
  138. intx140 tointegral -0.00 -> -0
  139. intx141 tointegral -0.0 -> -0
  140. intx142 tointegral -0 -> -0
  141. intx143 tointegral -0E-3 -> -0
  142. intx144 tointegral -0E-2 -> -0
  143. intx145 tointegral -0E-1 -> -0
  144. intx146 tointegral -0E-0 -> -0
  145. intx147 tointegral -0E+1 -> -0E+1
  146. intx148 tointegral -0E+2 -> -0E+2
  147. intx149 tointegral -0E+3 -> -0E+3
  148. intx150 tointegral -0E+4 -> -0E+4
  149. intx151 tointegral -0E+5 -> -0E+5
  150. -- propagating NaNs
  151. intx152 tointegral NaN808 -> NaN808
  152. intx153 tointegral sNaN080 -> NaN80 Invalid_operation
  153. intx154 tointegral -NaN808 -> -NaN808
  154. intx155 tointegral -sNaN080 -> -NaN80 Invalid_operation
  155. intx156 tointegral -NaN -> -NaN
  156. intx157 tointegral -sNaN -> -NaN Invalid_operation
  157. -- examples
  158. rounding: half_up
  159. precision: 9
  160. intx200 tointegral 2.1 -> 2
  161. intx201 tointegral 100 -> 100
  162. intx202 tointegral 100.0 -> 100
  163. intx203 tointegral 101.5 -> 102
  164. intx204 tointegral -101.5 -> -102
  165. intx205 tointegral 10E+5 -> 1.0E+6
  166. intx206 tointegral 7.89E+77 -> 7.89E+77
  167. intx207 tointegral -Inf -> -Infinity
  168. -- all rounding modes
  169. rounding: half_even
  170. intx210 tointegral 55.5 -> 56
  171. intx211 tointegral 56.5 -> 56
  172. intx212 tointegral 57.5 -> 58
  173. intx213 tointegral -55.5 -> -56
  174. intx214 tointegral -56.5 -> -56
  175. intx215 tointegral -57.5 -> -58
  176. rounding: half_up
  177. intx220 tointegral 55.5 -> 56
  178. intx221 tointegral 56.5 -> 57
  179. intx222 tointegral 57.5 -> 58
  180. intx223 tointegral -55.5 -> -56
  181. intx224 tointegral -56.5 -> -57
  182. intx225 tointegral -57.5 -> -58
  183. rounding: half_down
  184. intx230 tointegral 55.5 -> 55
  185. intx231 tointegral 56.5 -> 56
  186. intx232 tointegral 57.5 -> 57
  187. intx233 tointegral -55.5 -> -55
  188. intx234 tointegral -56.5 -> -56
  189. intx235 tointegral -57.5 -> -57
  190. rounding: up
  191. intx240 tointegral 55.3 -> 56
  192. intx241 tointegral 56.3 -> 57
  193. intx242 tointegral 57.3 -> 58
  194. intx243 tointegral -55.3 -> -56
  195. intx244 tointegral -56.3 -> -57
  196. intx245 tointegral -57.3 -> -58
  197. rounding: down
  198. intx250 tointegral 55.7 -> 55
  199. intx251 tointegral 56.7 -> 56
  200. intx252 tointegral 57.7 -> 57
  201. intx253 tointegral -55.7 -> -55
  202. intx254 tointegral -56.7 -> -56
  203. intx255 tointegral -57.7 -> -57
  204. rounding: ceiling
  205. intx260 tointegral 55.3 -> 56
  206. intx261 tointegral 56.3 -> 57
  207. intx262 tointegral 57.3 -> 58
  208. intx263 tointegral -55.3 -> -55
  209. intx264 tointegral -56.3 -> -56
  210. intx265 tointegral -57.3 -> -57
  211. rounding: floor
  212. intx270 tointegral 55.7 -> 55
  213. intx271 tointegral 56.7 -> 56
  214. intx272 tointegral 57.7 -> 57
  215. intx273 tointegral -55.7 -> -56
  216. intx274 tointegral -56.7 -> -57
  217. intx275 tointegral -57.7 -> -58