abs.decTest 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ------------------------------------------------------------------------
  2. -- abs.decTest -- decimal absolute value --
  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. -- This set of tests primarily tests the existence of the operator.
  22. -- Additon, subtraction, rounding, and more overflows are tested
  23. -- elsewhere.
  24. precision: 9
  25. rounding: half_up
  26. maxExponent: 384
  27. minexponent: -383
  28. extended: 1
  29. absx001 abs '1' -> '1'
  30. absx002 abs '-1' -> '1'
  31. absx003 abs '1.00' -> '1.00'
  32. absx004 abs '-1.00' -> '1.00'
  33. absx005 abs '0' -> '0'
  34. absx006 abs '0.00' -> '0.00'
  35. absx007 abs '00.0' -> '0.0'
  36. absx008 abs '00.00' -> '0.00'
  37. absx009 abs '00' -> '0'
  38. absx010 abs '-2' -> '2'
  39. absx011 abs '2' -> '2'
  40. absx012 abs '-2.00' -> '2.00'
  41. absx013 abs '2.00' -> '2.00'
  42. absx014 abs '-0' -> '0'
  43. absx015 abs '-0.00' -> '0.00'
  44. absx016 abs '-00.0' -> '0.0'
  45. absx017 abs '-00.00' -> '0.00'
  46. absx018 abs '-00' -> '0'
  47. absx020 abs '-2000000' -> '2000000'
  48. absx021 abs '2000000' -> '2000000'
  49. precision: 7
  50. absx022 abs '-2000000' -> '2000000'
  51. absx023 abs '2000000' -> '2000000'
  52. precision: 6
  53. absx024 abs '-2000000' -> '2.00000E+6' Rounded
  54. absx025 abs '2000000' -> '2.00000E+6' Rounded
  55. precision: 3
  56. absx026 abs '-2000000' -> '2.00E+6' Rounded
  57. absx027 abs '2000000' -> '2.00E+6' Rounded
  58. absx030 abs '+0.1' -> '0.1'
  59. absx031 abs '-0.1' -> '0.1'
  60. absx032 abs '+0.01' -> '0.01'
  61. absx033 abs '-0.01' -> '0.01'
  62. absx034 abs '+0.001' -> '0.001'
  63. absx035 abs '-0.001' -> '0.001'
  64. absx036 abs '+0.000001' -> '0.000001'
  65. absx037 abs '-0.000001' -> '0.000001'
  66. absx038 abs '+0.000000000001' -> '1E-12'
  67. absx039 abs '-0.000000000001' -> '1E-12'
  68. -- examples from decArith
  69. precision: 9
  70. absx040 abs '2.1' -> '2.1'
  71. absx041 abs '-100' -> '100'
  72. absx042 abs '101.5' -> '101.5'
  73. absx043 abs '-101.5' -> '101.5'
  74. -- more fixed, potential LHS swaps/overlays if done by subtract 0
  75. precision: 9
  76. absx060 abs '-56267E-10' -> '0.0000056267'
  77. absx061 abs '-56267E-5' -> '0.56267'
  78. absx062 abs '-56267E-2' -> '562.67'
  79. absx063 abs '-56267E-1' -> '5626.7'
  80. absx065 abs '-56267E-0' -> '56267'
  81. -- overflow tests
  82. maxexponent: 999999999
  83. minexponent: -999999999
  84. precision: 3
  85. absx120 abs 9.999E+999999999 -> Infinity Inexact Overflow Rounded
  86. -- subnormals and underflow
  87. precision: 3
  88. maxexponent: 999
  89. minexponent: -999
  90. absx210 abs 1.00E-999 -> 1.00E-999
  91. absx211 abs 0.1E-999 -> 1E-1000 Subnormal
  92. absx212 abs 0.10E-999 -> 1.0E-1000 Subnormal
  93. absx213 abs 0.100E-999 -> 1.0E-1000 Subnormal Rounded
  94. absx214 abs 0.01E-999 -> 1E-1001 Subnormal
  95. -- next is rounded to Emin
  96. absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
  97. absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
  98. absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
  99. absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  100. absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  101. absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  102. absx230 abs -1.00E-999 -> 1.00E-999
  103. absx231 abs -0.1E-999 -> 1E-1000 Subnormal
  104. absx232 abs -0.10E-999 -> 1.0E-1000 Subnormal
  105. absx233 abs -0.100E-999 -> 1.0E-1000 Subnormal Rounded
  106. absx234 abs -0.01E-999 -> 1E-1001 Subnormal
  107. -- next is rounded to Emin
  108. absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
  109. absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
  110. absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
  111. absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  112. absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  113. absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
  114. -- long operand tests
  115. maxexponent: 999
  116. minexponent: -999
  117. precision: 9
  118. absx301 abs 12345678000 -> 1.23456780E+10 Rounded
  119. absx302 abs 1234567800 -> 1.23456780E+9 Rounded
  120. absx303 abs 1234567890 -> 1.23456789E+9 Rounded
  121. absx304 abs 1234567891 -> 1.23456789E+9 Inexact Rounded
  122. absx305 abs 12345678901 -> 1.23456789E+10 Inexact Rounded
  123. absx306 abs 1234567896 -> 1.23456790E+9 Inexact Rounded
  124. precision: 15
  125. absx321 abs 12345678000 -> 12345678000
  126. absx322 abs 1234567800 -> 1234567800
  127. absx323 abs 1234567890 -> 1234567890
  128. absx324 abs 1234567891 -> 1234567891
  129. absx325 abs 12345678901 -> 12345678901
  130. absx326 abs 1234567896 -> 1234567896
  131. -- Specials
  132. precision: 9
  133. -- specials
  134. absx520 abs 'Inf' -> 'Infinity'
  135. absx521 abs '-Inf' -> 'Infinity'
  136. absx522 abs NaN -> NaN
  137. absx523 abs sNaN -> NaN Invalid_operation
  138. absx524 abs NaN22 -> NaN22
  139. absx525 abs sNaN33 -> NaN33 Invalid_operation
  140. absx526 abs -NaN22 -> -NaN22
  141. absx527 abs -sNaN33 -> -NaN33 Invalid_operation
  142. -- Null tests
  143. absx900 abs # -> NaN Invalid_operation