Raymond Hettinger | 7c85fa4 | 2004-07-01 11:01:35 +0000 | [diff] [blame] | 1 | ------------------------------------------------------------------------ |
| 2 | -- integer.decTest -- round decimal to integer -- |
| 3 | -- Copyright (c) IBM Corporation, 2001, 2003. 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.26 |
| 21 | |
| 22 | -- This set of tests tests the extended specification 'round-to-integer' |
| 23 | -- operation (from IEEE 854). All non-zero results are defined as |
| 24 | -- being those from either plus or rescale, so those are assumed to have |
| 25 | -- been tested. |
| 26 | |
| 27 | extended: 1 |
| 28 | precision: 9 |
| 29 | rounding: half_up |
| 30 | maxExponent: 999 |
| 31 | minExponent: -999 |
| 32 | |
| 33 | intx001 integer 0 -> 0 |
| 34 | intx002 integer 0.0 -> 0 |
| 35 | intx003 integer 0.1 -> 0 Rounded Inexact |
| 36 | intx004 integer 0.2 -> 0 Rounded Inexact |
| 37 | intx005 integer 0.3 -> 0 Rounded Inexact |
| 38 | intx006 integer 0.4 -> 0 Rounded Inexact |
| 39 | intx007 integer 0.5 -> 1 Rounded Inexact |
| 40 | intx008 integer 0.6 -> 1 Rounded Inexact |
| 41 | intx009 integer 0.7 -> 1 Rounded Inexact |
| 42 | intx010 integer 0.8 -> 1 Rounded Inexact |
| 43 | intx011 integer 0.9 -> 1 Rounded Inexact |
| 44 | intx012 integer 1 -> 1 |
| 45 | intx013 integer 1.0 -> 1 Rounded |
| 46 | intx014 integer 1.1 -> 1 Rounded Inexact |
| 47 | intx015 integer 1.2 -> 1 Rounded Inexact |
| 48 | intx016 integer 1.3 -> 1 Rounded Inexact |
| 49 | intx017 integer 1.4 -> 1 Rounded Inexact |
| 50 | intx018 integer 1.5 -> 2 Rounded Inexact |
| 51 | intx019 integer 1.6 -> 2 Rounded Inexact |
| 52 | intx020 integer 1.7 -> 2 Rounded Inexact |
| 53 | intx021 integer 1.8 -> 2 Rounded Inexact |
| 54 | intx022 integer 1.9 -> 2 Rounded Inexact |
| 55 | -- negatives |
| 56 | intx031 integer -0 -> -0 |
| 57 | intx032 integer -0.0 -> -0 |
| 58 | intx033 integer -0.1 -> -0 Rounded Inexact |
| 59 | intx034 integer -0.2 -> -0 Rounded Inexact |
| 60 | intx035 integer -0.3 -> -0 Rounded Inexact |
| 61 | intx036 integer -0.4 -> -0 Rounded Inexact |
| 62 | intx037 integer -0.5 -> -1 Rounded Inexact |
| 63 | intx038 integer -0.6 -> -1 Rounded Inexact |
| 64 | intx039 integer -0.7 -> -1 Rounded Inexact |
| 65 | intx040 integer -0.8 -> -1 Rounded Inexact |
| 66 | intx041 integer -0.9 -> -1 Rounded Inexact |
| 67 | intx042 integer -1 -> -1 |
| 68 | intx043 integer -1.0 -> -1 Rounded |
| 69 | intx044 integer -1.1 -> -1 Rounded Inexact |
| 70 | intx045 integer -1.2 -> -1 Rounded Inexact |
| 71 | intx046 integer -1.3 -> -1 Rounded Inexact |
| 72 | intx047 integer -1.4 -> -1 Rounded Inexact |
| 73 | intx048 integer -1.5 -> -2 Rounded Inexact |
| 74 | intx049 integer -1.6 -> -2 Rounded Inexact |
| 75 | intx050 integer -1.7 -> -2 Rounded Inexact |
| 76 | intx051 integer -1.8 -> -2 Rounded Inexact |
| 77 | intx052 integer -1.9 -> -2 Rounded Inexact |
| 78 | intx053 integer 10E+30 -> NaN Invalid_operation |
| 79 | intx054 integer -10E+30 -> NaN Invalid_operation |
| 80 | |
| 81 | -- numbers around precision |
| 82 | precision: 9 |
| 83 | intx060 integer '56267E-10' -> '0' Inexact Rounded |
| 84 | intx061 integer '56267E-5' -> '1' Inexact Rounded |
| 85 | intx062 integer '56267E-2' -> '563' Inexact Rounded |
| 86 | intx063 integer '56267E-1' -> '5627' Inexact Rounded |
| 87 | intx065 integer '56267E-0' -> '56267' |
| 88 | intx066 integer '56267E+0' -> '56267' |
| 89 | intx067 integer '56267E+1' -> '562670' |
| 90 | intx068 integer '56267E+2' -> '5626700' |
| 91 | intx069 integer '56267E+3' -> '56267000' |
| 92 | intx070 integer '56267E+4' -> '562670000' |
| 93 | intx071 integer '56267E+5' -> NaN Invalid_operation |
| 94 | intx072 integer '56267E+6' -> NaN Invalid_operation |
| 95 | intx080 integer '-56267E-10' -> '-0' Inexact Rounded |
| 96 | intx081 integer '-56267E-5' -> '-1' Inexact Rounded |
| 97 | intx082 integer '-56267E-2' -> '-563' Inexact Rounded |
| 98 | intx083 integer '-56267E-1' -> '-5627' Inexact Rounded |
| 99 | intx085 integer '-56267E-0' -> '-56267' |
| 100 | intx086 integer '-56267E+0' -> '-56267' |
| 101 | intx087 integer '-56267E+1' -> '-562670' |
| 102 | intx088 integer '-56267E+2' -> '-5626700' |
| 103 | intx089 integer '-56267E+3' -> '-56267000' |
| 104 | intx090 integer '-56267E+4' -> '-562670000' |
| 105 | intx091 integer '-56267E+5' -> NaN Invalid_operation |
| 106 | intx092 integer '-56267E+6' -> NaN Invalid_operation |
| 107 | |
| 108 | -- specials and zeros |
| 109 | intx120 integer 'Inf' -> NaN Invalid_operation |
| 110 | intx121 integer '-Inf' -> NaN Invalid_operation |
| 111 | intx122 integer NaN -> NaN |
| 112 | intx123 integer sNaN -> NaN Invalid_operation |
| 113 | intx124 integer 0 -> 0 |
| 114 | intx125 integer -0 -> -0 |
| 115 | intx126 integer 0.000 -> 0 |
| 116 | intx127 integer 0.00 -> 0 |
| 117 | intx128 integer 0.0 -> 0 |
| 118 | intx129 integer 0 -> 0 |
| 119 | intx130 integer 0E-3 -> 0 |
| 120 | intx131 integer 0E-2 -> 0 |
| 121 | intx132 integer 0E-1 -> 0 |
| 122 | intx133 integer 0E-0 -> 0 |
| 123 | intx134 integer 0E+1 -> 0 |
| 124 | intx135 integer 0E+2 -> 0 |
| 125 | intx136 integer 0E+3 -> 0 |
| 126 | intx137 integer 0E+4 -> 0 |
| 127 | intx138 integer 0E+5 -> 0 |
| 128 | intx139 integer -0.000 -> -0 |
| 129 | intx140 integer -0.00 -> -0 |
| 130 | intx141 integer -0.0 -> -0 |
| 131 | intx142 integer -0 -> -0 |
| 132 | intx143 integer -0E-3 -> -0 |
| 133 | intx144 integer -0E-2 -> -0 |
| 134 | intx145 integer -0E-1 -> -0 |
| 135 | intx146 integer -0E-0 -> -0 |
| 136 | intx147 integer -0E+1 -> -0 |
| 137 | intx148 integer -0E+2 -> -0 |
| 138 | intx149 integer -0E+3 -> -0 |
| 139 | intx150 integer -0E+4 -> -0 |
| 140 | intx151 integer -0E+5 -> -0 |
| 141 | |
| 142 | -- examples |
| 143 | rounding: half_up |
| 144 | precision: 9 |
| 145 | intx200 integer 2.1 -> 2 Rounded Inexact |
| 146 | intx201 integer 100 -> 100 |
| 147 | intx202 integer 100.0 -> 100 Rounded |
| 148 | intx203 integer 101.5 -> 102 Rounded Inexact |
| 149 | intx204 integer -101.5 -> -102 Rounded Inexact |
| 150 | intx205 integer 10E+5 -> 1000000 |
| 151 | |