clamp.decTest 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. ------------------------------------------------------------------------
  2. -- clamp.decTest -- clamped exponent tests (format-independent) --
  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. version: 2.59
  21. -- This set of tests uses the same limits as the 8-byte concrete
  22. -- representation, but applies clamping without using format-specific
  23. -- conversions.
  24. extended: 1
  25. precision: 16
  26. rounding: half_even
  27. maxExponent: 384
  28. minExponent: -383
  29. clamp: 1
  30. -- General testcases
  31. -- Normality
  32. clam010 apply 1234567890123456 -> 1234567890123456
  33. clam011 apply 1234567890123456.0 -> 1234567890123456 Rounded
  34. clam012 apply 1234567890123456.1 -> 1234567890123456 Rounded Inexact
  35. clam013 apply -1234567890123456 -> -1234567890123456
  36. clam014 apply -1234567890123456.0 -> -1234567890123456 Rounded
  37. clam015 apply -1234567890123456.1 -> -1234567890123456 Rounded Inexact
  38. -- Nmax and similar
  39. clam022 apply 9.999999999999999E+384 -> 9.999999999999999E+384
  40. clam024 apply 1.234567890123456E+384 -> 1.234567890123456E+384
  41. -- fold-downs (more below)
  42. clam030 apply 1.23E+384 -> 1.230000000000000E+384 Clamped
  43. clam032 apply 1E+384 -> 1.000000000000000E+384 Clamped
  44. clam051 apply 12345 -> 12345
  45. clam053 apply 1234 -> 1234
  46. clam055 apply 123 -> 123
  47. clam057 apply 12 -> 12
  48. clam059 apply 1 -> 1
  49. clam061 apply 1.23 -> 1.23
  50. clam063 apply 123.45 -> 123.45
  51. -- Nmin and below
  52. clam071 apply 1E-383 -> 1E-383
  53. clam073 apply 1.000000000000000E-383 -> 1.000000000000000E-383
  54. clam075 apply 1.000000000000001E-383 -> 1.000000000000001E-383
  55. clam077 apply 0.100000000000000E-383 -> 1.00000000000000E-384 Subnormal
  56. clam079 apply 0.000000000000010E-383 -> 1.0E-397 Subnormal
  57. clam081 apply 0.00000000000001E-383 -> 1E-397 Subnormal
  58. clam083 apply 0.000000000000001E-383 -> 1E-398 Subnormal
  59. -- underflows
  60. clam090 apply 1e-398 -> #0000000000000001 Subnormal
  61. clam091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded
  62. clam092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
  63. clam093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
  64. clam094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
  65. clam095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded
  66. clam096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
  67. clam097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
  68. clam098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
  69. clam099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded Clamped
  70. -- Same again, negatives
  71. -- Nmax and similar
  72. clam122 apply -9.999999999999999E+384 -> -9.999999999999999E+384
  73. clam124 apply -1.234567890123456E+384 -> -1.234567890123456E+384
  74. -- fold-downs (more below)
  75. clam130 apply -1.23E+384 -> -1.230000000000000E+384 Clamped
  76. clam132 apply -1E+384 -> -1.000000000000000E+384 Clamped
  77. clam151 apply -12345 -> -12345
  78. clam153 apply -1234 -> -1234
  79. clam155 apply -123 -> -123
  80. clam157 apply -12 -> -12
  81. clam159 apply -1 -> -1
  82. clam161 apply -1.23 -> -1.23
  83. clam163 apply -123.45 -> -123.45
  84. -- Nmin and below
  85. clam171 apply -1E-383 -> -1E-383
  86. clam173 apply -1.000000000000000E-383 -> -1.000000000000000E-383
  87. clam175 apply -1.000000000000001E-383 -> -1.000000000000001E-383
  88. clam177 apply -0.100000000000000E-383 -> -1.00000000000000E-384 Subnormal
  89. clam179 apply -0.000000000000010E-383 -> -1.0E-397 Subnormal
  90. clam181 apply -0.00000000000001E-383 -> -1E-397 Subnormal
  91. clam183 apply -0.000000000000001E-383 -> -1E-398 Subnormal
  92. -- underflows
  93. clam189 apply -1e-398 -> #8000000000000001 Subnormal
  94. clam190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
  95. clam191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded
  96. clam192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
  97. clam193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
  98. clam194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
  99. clam195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded
  100. clam196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
  101. clam197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
  102. clam198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
  103. clam199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded Clamped
  104. -- zeros
  105. clam401 apply 0E-500 -> 0E-398 Clamped
  106. clam402 apply 0E-400 -> 0E-398 Clamped
  107. clam403 apply 0E-398 -> 0E-398
  108. clam404 apply 0.000000000000000E-383 -> 0E-398
  109. clam405 apply 0E-2 -> 0.00
  110. clam406 apply 0 -> 0
  111. clam407 apply 0E+3 -> 0E+3
  112. clam408 apply 0E+369 -> 0E+369
  113. -- clamped zeros...
  114. clam410 apply 0E+370 -> 0E+369 Clamped
  115. clam411 apply 0E+384 -> 0E+369 Clamped
  116. clam412 apply 0E+400 -> 0E+369 Clamped
  117. clam413 apply 0E+500 -> 0E+369 Clamped
  118. -- negative zeros
  119. clam420 apply -0E-500 -> -0E-398 Clamped
  120. clam421 apply -0E-400 -> -0E-398 Clamped
  121. clam422 apply -0E-398 -> -0E-398
  122. clam423 apply -0.000000000000000E-383 -> -0E-398
  123. clam424 apply -0E-2 -> -0.00
  124. clam425 apply -0 -> -0
  125. clam426 apply -0E+3 -> -0E+3
  126. clam427 apply -0E+369 -> -0E+369
  127. -- clamped zeros...
  128. clam431 apply -0E+370 -> -0E+369 Clamped
  129. clam432 apply -0E+384 -> -0E+369 Clamped
  130. clam433 apply -0E+400 -> -0E+369 Clamped
  131. clam434 apply -0E+500 -> -0E+369 Clamped
  132. -- fold-down full sequence
  133. clam601 apply 1E+384 -> 1.000000000000000E+384 Clamped
  134. clam603 apply 1E+383 -> 1.00000000000000E+383 Clamped
  135. clam605 apply 1E+382 -> 1.0000000000000E+382 Clamped
  136. clam607 apply 1E+381 -> 1.000000000000E+381 Clamped
  137. clam609 apply 1E+380 -> 1.00000000000E+380 Clamped
  138. clam611 apply 1E+379 -> 1.0000000000E+379 Clamped
  139. clam613 apply 1E+378 -> 1.000000000E+378 Clamped
  140. clam615 apply 1E+377 -> 1.00000000E+377 Clamped
  141. clam617 apply 1E+376 -> 1.0000000E+376 Clamped
  142. clam619 apply 1E+375 -> 1.000000E+375 Clamped
  143. clam621 apply 1E+374 -> 1.00000E+374 Clamped
  144. clam623 apply 1E+373 -> 1.0000E+373 Clamped
  145. clam625 apply 1E+372 -> 1.000E+372 Clamped
  146. clam627 apply 1E+371 -> 1.00E+371 Clamped
  147. clam629 apply 1E+370 -> 1.0E+370 Clamped
  148. clam631 apply 1E+369 -> 1E+369
  149. clam633 apply 1E+368 -> 1E+368
  150. -- same with 9s
  151. clam641 apply 9E+384 -> 9.000000000000000E+384 Clamped
  152. clam643 apply 9E+383 -> 9.00000000000000E+383 Clamped
  153. clam645 apply 9E+382 -> 9.0000000000000E+382 Clamped
  154. clam647 apply 9E+381 -> 9.000000000000E+381 Clamped
  155. clam649 apply 9E+380 -> 9.00000000000E+380 Clamped
  156. clam651 apply 9E+379 -> 9.0000000000E+379 Clamped
  157. clam653 apply 9E+378 -> 9.000000000E+378 Clamped
  158. clam655 apply 9E+377 -> 9.00000000E+377 Clamped
  159. clam657 apply 9E+376 -> 9.0000000E+376 Clamped
  160. clam659 apply 9E+375 -> 9.000000E+375 Clamped
  161. clam661 apply 9E+374 -> 9.00000E+374 Clamped
  162. clam663 apply 9E+373 -> 9.0000E+373 Clamped
  163. clam665 apply 9E+372 -> 9.000E+372 Clamped
  164. clam667 apply 9E+371 -> 9.00E+371 Clamped
  165. clam669 apply 9E+370 -> 9.0E+370 Clamped
  166. clam671 apply 9E+369 -> 9E+369
  167. clam673 apply 9E+368 -> 9E+368
  168. -- subnormals clamped to 0-Etiny
  169. precision: 16
  170. maxExponent: 384
  171. minExponent: -383
  172. clam681 apply 7E-398 -> 7E-398 Subnormal
  173. clam682 apply 0E-398 -> 0E-398
  174. clam683 apply 7E-399 -> 1E-398 Subnormal Underflow Inexact Rounded
  175. clam684 apply 4E-399 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
  176. clam685 apply 7E-400 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
  177. clam686 apply 7E-401 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded
  178. clam687 apply 0E-399 -> 0E-398 Clamped
  179. clam688 apply 0E-400 -> 0E-398 Clamped
  180. clam689 apply 0E-401 -> 0E-398 Clamped
  181. -- example from documentation
  182. precision: 7
  183. rounding: half_even
  184. maxExponent: +96
  185. minExponent: -95
  186. clamp: 0
  187. clam700 apply 1.23E+96 -> 1.23E+96
  188. clamp: 1
  189. clam701 apply 1.23E+96 -> 1.230000E+96 Clamped