1------------------------------------------------------------------------ 2-- tointegralx.decTest -- round decimal to integral value, exact -- 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------------------------------------------------------------------------ 20version: 2.59 21 22-- This set of tests tests the extended specification 'round-to-integral 23-- value' operation (from IEEE 854, later modified in 754r). 24-- All non-zero results are defined as being those from either copy or 25-- quantize, so those are assumed to have been tested. 26 27-- This tests toIntegraExact, which may set Inexact 28 29extended: 1 30precision: 9 31rounding: half_up 32maxExponent: 999 33minExponent: -999 34 35intxx001 tointegralx 0 -> 0 36intxx002 tointegralx 0.0 -> 0 37intxx003 tointegralx 0.1 -> 0 Inexact Rounded 38intxx004 tointegralx 0.2 -> 0 Inexact Rounded 39intxx005 tointegralx 0.3 -> 0 Inexact Rounded 40intxx006 tointegralx 0.4 -> 0 Inexact Rounded 41intxx007 tointegralx 0.5 -> 1 Inexact Rounded 42intxx008 tointegralx 0.6 -> 1 Inexact Rounded 43intxx009 tointegralx 0.7 -> 1 Inexact Rounded 44intxx010 tointegralx 0.8 -> 1 Inexact Rounded 45intxx011 tointegralx 0.9 -> 1 Inexact Rounded 46intxx012 tointegralx 1 -> 1 47intxx013 tointegralx 1.0 -> 1 Rounded 48intxx014 tointegralx 1.1 -> 1 Inexact Rounded 49intxx015 tointegralx 1.2 -> 1 Inexact Rounded 50intxx016 tointegralx 1.3 -> 1 Inexact Rounded 51intxx017 tointegralx 1.4 -> 1 Inexact Rounded 52intxx018 tointegralx 1.5 -> 2 Inexact Rounded 53intxx019 tointegralx 1.6 -> 2 Inexact Rounded 54intxx020 tointegralx 1.7 -> 2 Inexact Rounded 55intxx021 tointegralx 1.8 -> 2 Inexact Rounded 56intxx022 tointegralx 1.9 -> 2 Inexact Rounded 57-- negatives 58intxx031 tointegralx -0 -> -0 59intxx032 tointegralx -0.0 -> -0 60intxx033 tointegralx -0.1 -> -0 Inexact Rounded 61intxx034 tointegralx -0.2 -> -0 Inexact Rounded 62intxx035 tointegralx -0.3 -> -0 Inexact Rounded 63intxx036 tointegralx -0.4 -> -0 Inexact Rounded 64intxx037 tointegralx -0.5 -> -1 Inexact Rounded 65intxx038 tointegralx -0.6 -> -1 Inexact Rounded 66intxx039 tointegralx -0.7 -> -1 Inexact Rounded 67intxx040 tointegralx -0.8 -> -1 Inexact Rounded 68intxx041 tointegralx -0.9 -> -1 Inexact Rounded 69intxx042 tointegralx -1 -> -1 70intxx043 tointegralx -1.0 -> -1 Rounded 71intxx044 tointegralx -1.1 -> -1 Inexact Rounded 72intxx045 tointegralx -1.2 -> -1 Inexact Rounded 73intxx046 tointegralx -1.3 -> -1 Inexact Rounded 74intxx047 tointegralx -1.4 -> -1 Inexact Rounded 75intxx048 tointegralx -1.5 -> -2 Inexact Rounded 76intxx049 tointegralx -1.6 -> -2 Inexact Rounded 77intxx050 tointegralx -1.7 -> -2 Inexact Rounded 78intxx051 tointegralx -1.8 -> -2 Inexact Rounded 79intxx052 tointegralx -1.9 -> -2 Inexact Rounded 80-- next two would be NaN using quantize(x, 0) 81intxx053 tointegralx 10E+30 -> 1.0E+31 82intxx054 tointegralx -10E+30 -> -1.0E+31 83 84-- numbers around precision 85precision: 9 86intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded 87intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded 88intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded 89intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded 90intxx065 tointegralx '56267E-0' -> '56267' 91intxx066 tointegralx '56267E+0' -> '56267' 92intxx067 tointegralx '56267E+1' -> '5.6267E+5' 93intxx068 tointegralx '56267E+2' -> '5.6267E+6' 94intxx069 tointegralx '56267E+3' -> '5.6267E+7' 95intxx070 tointegralx '56267E+4' -> '5.6267E+8' 96intxx071 tointegralx '56267E+5' -> '5.6267E+9' 97intxx072 tointegralx '56267E+6' -> '5.6267E+10' 98intxx073 tointegralx '1.23E+96' -> '1.23E+96' 99intxx074 tointegralx '1.23E+384' -> '1.23E+384' 100intxx075 tointegralx '1.23E+999' -> '1.23E+999' 101 102intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded 103intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded 104intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded 105intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded 106intxx085 tointegralx '-56267E-0' -> '-56267' 107intxx086 tointegralx '-56267E+0' -> '-56267' 108intxx087 tointegralx '-56267E+1' -> '-5.6267E+5' 109intxx088 tointegralx '-56267E+2' -> '-5.6267E+6' 110intxx089 tointegralx '-56267E+3' -> '-5.6267E+7' 111intxx090 tointegralx '-56267E+4' -> '-5.6267E+8' 112intxx091 tointegralx '-56267E+5' -> '-5.6267E+9' 113intxx092 tointegralx '-56267E+6' -> '-5.6267E+10' 114intxx093 tointegralx '-1.23E+96' -> '-1.23E+96' 115intxx094 tointegralx '-1.23E+384' -> '-1.23E+384' 116intxx095 tointegralx '-1.23E+999' -> '-1.23E+999' 117 118-- subnormal inputs 119intxx100 tointegralx 1E-999 -> 0 Inexact Rounded 120intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded 121intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded 122intxx103 tointegralx 0E-999 -> 0 123 124-- specials and zeros 125intxx120 tointegralx 'Inf' -> Infinity 126intxx121 tointegralx '-Inf' -> -Infinity 127intxx122 tointegralx NaN -> NaN 128intxx123 tointegralx sNaN -> NaN Invalid_operation 129intxx124 tointegralx 0 -> 0 130intxx125 tointegralx -0 -> -0 131intxx126 tointegralx 0.000 -> 0 132intxx127 tointegralx 0.00 -> 0 133intxx128 tointegralx 0.0 -> 0 134intxx129 tointegralx 0 -> 0 135intxx130 tointegralx 0E-3 -> 0 136intxx131 tointegralx 0E-2 -> 0 137intxx132 tointegralx 0E-1 -> 0 138intxx133 tointegralx 0E-0 -> 0 139intxx134 tointegralx 0E+1 -> 0E+1 140intxx135 tointegralx 0E+2 -> 0E+2 141intxx136 tointegralx 0E+3 -> 0E+3 142intxx137 tointegralx 0E+4 -> 0E+4 143intxx138 tointegralx 0E+5 -> 0E+5 144intxx139 tointegralx -0.000 -> -0 145intxx140 tointegralx -0.00 -> -0 146intxx141 tointegralx -0.0 -> -0 147intxx142 tointegralx -0 -> -0 148intxx143 tointegralx -0E-3 -> -0 149intxx144 tointegralx -0E-2 -> -0 150intxx145 tointegralx -0E-1 -> -0 151intxx146 tointegralx -0E-0 -> -0 152intxx147 tointegralx -0E+1 -> -0E+1 153intxx148 tointegralx -0E+2 -> -0E+2 154intxx149 tointegralx -0E+3 -> -0E+3 155intxx150 tointegralx -0E+4 -> -0E+4 156intxx151 tointegralx -0E+5 -> -0E+5 157-- propagating NaNs 158intxx152 tointegralx NaN808 -> NaN808 159intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation 160intxx154 tointegralx -NaN808 -> -NaN808 161intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation 162intxx156 tointegralx -NaN -> -NaN 163intxx157 tointegralx -sNaN -> -NaN Invalid_operation 164 165-- examples 166rounding: half_up 167precision: 9 168intxx200 tointegralx 2.1 -> 2 Inexact Rounded 169intxx201 tointegralx 100 -> 100 170intxx202 tointegralx 100.0 -> 100 Rounded 171intxx203 tointegralx 101.5 -> 102 Inexact Rounded 172intxx204 tointegralx -101.5 -> -102 Inexact Rounded 173intxx205 tointegralx 10E+5 -> 1.0E+6 174intxx206 tointegralx 7.89E+77 -> 7.89E+77 175intxx207 tointegralx -Inf -> -Infinity 176 177 178-- all rounding modes 179rounding: half_even 180 181intxx210 tointegralx 55.5 -> 56 Inexact Rounded 182intxx211 tointegralx 56.5 -> 56 Inexact Rounded 183intxx212 tointegralx 57.5 -> 58 Inexact Rounded 184intxx213 tointegralx -55.5 -> -56 Inexact Rounded 185intxx214 tointegralx -56.5 -> -56 Inexact Rounded 186intxx215 tointegralx -57.5 -> -58 Inexact Rounded 187 188rounding: half_up 189 190intxx220 tointegralx 55.5 -> 56 Inexact Rounded 191intxx221 tointegralx 56.5 -> 57 Inexact Rounded 192intxx222 tointegralx 57.5 -> 58 Inexact Rounded 193intxx223 tointegralx -55.5 -> -56 Inexact Rounded 194intxx224 tointegralx -56.5 -> -57 Inexact Rounded 195intxx225 tointegralx -57.5 -> -58 Inexact Rounded 196 197rounding: half_down 198 199intxx230 tointegralx 55.5 -> 55 Inexact Rounded 200intxx231 tointegralx 56.5 -> 56 Inexact Rounded 201intxx232 tointegralx 57.5 -> 57 Inexact Rounded 202intxx233 tointegralx -55.5 -> -55 Inexact Rounded 203intxx234 tointegralx -56.5 -> -56 Inexact Rounded 204intxx235 tointegralx -57.5 -> -57 Inexact Rounded 205 206rounding: up 207 208intxx240 tointegralx 55.3 -> 56 Inexact Rounded 209intxx241 tointegralx 56.3 -> 57 Inexact Rounded 210intxx242 tointegralx 57.3 -> 58 Inexact Rounded 211intxx243 tointegralx -55.3 -> -56 Inexact Rounded 212intxx244 tointegralx -56.3 -> -57 Inexact Rounded 213intxx245 tointegralx -57.3 -> -58 Inexact Rounded 214 215rounding: down 216 217intxx250 tointegralx 55.7 -> 55 Inexact Rounded 218intxx251 tointegralx 56.7 -> 56 Inexact Rounded 219intxx252 tointegralx 57.7 -> 57 Inexact Rounded 220intxx253 tointegralx -55.7 -> -55 Inexact Rounded 221intxx254 tointegralx -56.7 -> -56 Inexact Rounded 222intxx255 tointegralx -57.7 -> -57 Inexact Rounded 223 224rounding: ceiling 225 226intxx260 tointegralx 55.3 -> 56 Inexact Rounded 227intxx261 tointegralx 56.3 -> 57 Inexact Rounded 228intxx262 tointegralx 57.3 -> 58 Inexact Rounded 229intxx263 tointegralx -55.3 -> -55 Inexact Rounded 230intxx264 tointegralx -56.3 -> -56 Inexact Rounded 231intxx265 tointegralx -57.3 -> -57 Inexact Rounded 232 233rounding: floor 234 235intxx270 tointegralx 55.7 -> 55 Inexact Rounded 236intxx271 tointegralx 56.7 -> 56 Inexact Rounded 237intxx272 tointegralx 57.7 -> 57 Inexact Rounded 238intxx273 tointegralx -55.7 -> -56 Inexact Rounded 239intxx274 tointegralx -56.7 -> -57 Inexact Rounded 240intxx275 tointegralx -57.7 -> -58 Inexact Rounded 241 242-- Int and uInt32 edge values for testing conversions 243precision: 16 244intxx300 tointegralx -2147483646 -> -2147483646 245intxx301 tointegralx -2147483647 -> -2147483647 246intxx302 tointegralx -2147483648 -> -2147483648 247intxx303 tointegralx -2147483649 -> -2147483649 248intxx304 tointegralx 2147483646 -> 2147483646 249intxx305 tointegralx 2147483647 -> 2147483647 250intxx306 tointegralx 2147483648 -> 2147483648 251intxx307 tointegralx 2147483649 -> 2147483649 252intxx308 tointegralx 4294967294 -> 4294967294 253intxx309 tointegralx 4294967295 -> 4294967295 254intxx310 tointegralx 4294967296 -> 4294967296 255intxx311 tointegralx 4294967297 -> 4294967297 256