1------------------------------------------------------------------------ 2-- ddToIntegral.decTest -- round Double 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------------------------------------------------------------------------ 20version: 2.59 21 22-- This set of tests tests the extended specification 'round-to-integral 23-- value-exact' operations (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 extensively 26-- elsewhere; the tests here are for integrity, rounding mode, etc. 27-- Also, it is assumed the test harness will use these tests for both 28-- ToIntegralExact (which does set Inexact) and the fixed-name 29-- functions (which do not set Inexact). 30 31-- Note that decNumber implements an earlier definition of toIntegral 32-- which never sets Inexact; the decTest operator for that is called 33-- 'tointegral' instead of 'tointegralx'. 34 35precision: 16 36maxExponent: 384 37minExponent: -383 38extended: 1 39clamp: 1 40rounding: half_even 41 42ddintx001 tointegralx 0 -> 0 43ddintx002 tointegralx 0.0 -> 0 44ddintx003 tointegralx 0.1 -> 0 Inexact Rounded 45ddintx004 tointegralx 0.2 -> 0 Inexact Rounded 46ddintx005 tointegralx 0.3 -> 0 Inexact Rounded 47ddintx006 tointegralx 0.4 -> 0 Inexact Rounded 48ddintx007 tointegralx 0.5 -> 0 Inexact Rounded 49ddintx008 tointegralx 0.6 -> 1 Inexact Rounded 50ddintx009 tointegralx 0.7 -> 1 Inexact Rounded 51ddintx010 tointegralx 0.8 -> 1 Inexact Rounded 52ddintx011 tointegralx 0.9 -> 1 Inexact Rounded 53ddintx012 tointegralx 1 -> 1 54ddintx013 tointegralx 1.0 -> 1 Rounded 55ddintx014 tointegralx 1.1 -> 1 Inexact Rounded 56ddintx015 tointegralx 1.2 -> 1 Inexact Rounded 57ddintx016 tointegralx 1.3 -> 1 Inexact Rounded 58ddintx017 tointegralx 1.4 -> 1 Inexact Rounded 59ddintx018 tointegralx 1.5 -> 2 Inexact Rounded 60ddintx019 tointegralx 1.6 -> 2 Inexact Rounded 61ddintx020 tointegralx 1.7 -> 2 Inexact Rounded 62ddintx021 tointegralx 1.8 -> 2 Inexact Rounded 63ddintx022 tointegralx 1.9 -> 2 Inexact Rounded 64-- negatives 65ddintx031 tointegralx -0 -> -0 66ddintx032 tointegralx -0.0 -> -0 67ddintx033 tointegralx -0.1 -> -0 Inexact Rounded 68ddintx034 tointegralx -0.2 -> -0 Inexact Rounded 69ddintx035 tointegralx -0.3 -> -0 Inexact Rounded 70ddintx036 tointegralx -0.4 -> -0 Inexact Rounded 71ddintx037 tointegralx -0.5 -> -0 Inexact Rounded 72ddintx038 tointegralx -0.6 -> -1 Inexact Rounded 73ddintx039 tointegralx -0.7 -> -1 Inexact Rounded 74ddintx040 tointegralx -0.8 -> -1 Inexact Rounded 75ddintx041 tointegralx -0.9 -> -1 Inexact Rounded 76ddintx042 tointegralx -1 -> -1 77ddintx043 tointegralx -1.0 -> -1 Rounded 78ddintx044 tointegralx -1.1 -> -1 Inexact Rounded 79ddintx045 tointegralx -1.2 -> -1 Inexact Rounded 80ddintx046 tointegralx -1.3 -> -1 Inexact Rounded 81ddintx047 tointegralx -1.4 -> -1 Inexact Rounded 82ddintx048 tointegralx -1.5 -> -2 Inexact Rounded 83ddintx049 tointegralx -1.6 -> -2 Inexact Rounded 84ddintx050 tointegralx -1.7 -> -2 Inexact Rounded 85ddintx051 tointegralx -1.8 -> -2 Inexact Rounded 86ddintx052 tointegralx -1.9 -> -2 Inexact Rounded 87-- next two would be NaN using quantize(x, 0) 88ddintx053 tointegralx 10E+60 -> 1.0E+61 89ddintx054 tointegralx -10E+60 -> -1.0E+61 90 91-- numbers around precision 92ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded 93ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded 94ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded 95ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded 96ddintx065 tointegralx '56267E-0' -> '56267' 97ddintx066 tointegralx '56267E+0' -> '56267' 98ddintx067 tointegralx '56267E+1' -> '5.6267E+5' 99ddintx068 tointegralx '56267E+9' -> '5.6267E+13' 100ddintx069 tointegralx '56267E+10' -> '5.6267E+14' 101ddintx070 tointegralx '56267E+11' -> '5.6267E+15' 102ddintx071 tointegralx '56267E+12' -> '5.6267E+16' 103ddintx072 tointegralx '56267E+13' -> '5.6267E+17' 104ddintx073 tointegralx '1.23E+96' -> '1.23E+96' 105ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped 106 107ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded 108ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded 109ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded 110ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded 111ddintx085 tointegralx '-56267E-0' -> '-56267' 112ddintx086 tointegralx '-56267E+0' -> '-56267' 113ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5' 114ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13' 115ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14' 116ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15' 117ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16' 118ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17' 119ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96' 120ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped 121 122-- subnormal inputs 123ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded 124ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded 125ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded 126ddintx103 tointegralx 0E-299 -> 0 127 128-- specials and zeros 129ddintx120 tointegralx 'Inf' -> Infinity 130ddintx121 tointegralx '-Inf' -> -Infinity 131ddintx122 tointegralx NaN -> NaN 132ddintx123 tointegralx sNaN -> NaN Invalid_operation 133ddintx124 tointegralx 0 -> 0 134ddintx125 tointegralx -0 -> -0 135ddintx126 tointegralx 0.000 -> 0 136ddintx127 tointegralx 0.00 -> 0 137ddintx128 tointegralx 0.0 -> 0 138ddintx129 tointegralx 0 -> 0 139ddintx130 tointegralx 0E-3 -> 0 140ddintx131 tointegralx 0E-2 -> 0 141ddintx132 tointegralx 0E-1 -> 0 142ddintx133 tointegralx 0E-0 -> 0 143ddintx134 tointegralx 0E+1 -> 0E+1 144ddintx135 tointegralx 0E+2 -> 0E+2 145ddintx136 tointegralx 0E+3 -> 0E+3 146ddintx137 tointegralx 0E+4 -> 0E+4 147ddintx138 tointegralx 0E+5 -> 0E+5 148ddintx139 tointegralx -0.000 -> -0 149ddintx140 tointegralx -0.00 -> -0 150ddintx141 tointegralx -0.0 -> -0 151ddintx142 tointegralx -0 -> -0 152ddintx143 tointegralx -0E-3 -> -0 153ddintx144 tointegralx -0E-2 -> -0 154ddintx145 tointegralx -0E-1 -> -0 155ddintx146 tointegralx -0E-0 -> -0 156ddintx147 tointegralx -0E+1 -> -0E+1 157ddintx148 tointegralx -0E+2 -> -0E+2 158ddintx149 tointegralx -0E+3 -> -0E+3 159ddintx150 tointegralx -0E+4 -> -0E+4 160ddintx151 tointegralx -0E+5 -> -0E+5 161-- propagating NaNs 162ddintx152 tointegralx NaN808 -> NaN808 163ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation 164ddintx154 tointegralx -NaN808 -> -NaN808 165ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation 166ddintx156 tointegralx -NaN -> -NaN 167ddintx157 tointegralx -sNaN -> -NaN Invalid_operation 168 169-- examples 170rounding: half_up 171ddintx200 tointegralx 2.1 -> 2 Inexact Rounded 172ddintx201 tointegralx 100 -> 100 173ddintx202 tointegralx 100.0 -> 100 Rounded 174ddintx203 tointegralx 101.5 -> 102 Inexact Rounded 175ddintx204 tointegralx -101.5 -> -102 Inexact Rounded 176ddintx205 tointegralx 10E+5 -> 1.0E+6 177ddintx206 tointegralx 7.89E+77 -> 7.89E+77 178ddintx207 tointegralx -Inf -> -Infinity 179 180 181-- all rounding modes 182rounding: half_even 183ddintx210 tointegralx 55.5 -> 56 Inexact Rounded 184ddintx211 tointegralx 56.5 -> 56 Inexact Rounded 185ddintx212 tointegralx 57.5 -> 58 Inexact Rounded 186ddintx213 tointegralx -55.5 -> -56 Inexact Rounded 187ddintx214 tointegralx -56.5 -> -56 Inexact Rounded 188ddintx215 tointegralx -57.5 -> -58 Inexact Rounded 189 190rounding: half_up 191 192ddintx220 tointegralx 55.5 -> 56 Inexact Rounded 193ddintx221 tointegralx 56.5 -> 57 Inexact Rounded 194ddintx222 tointegralx 57.5 -> 58 Inexact Rounded 195ddintx223 tointegralx -55.5 -> -56 Inexact Rounded 196ddintx224 tointegralx -56.5 -> -57 Inexact Rounded 197ddintx225 tointegralx -57.5 -> -58 Inexact Rounded 198 199rounding: half_down 200 201ddintx230 tointegralx 55.5 -> 55 Inexact Rounded 202ddintx231 tointegralx 56.5 -> 56 Inexact Rounded 203ddintx232 tointegralx 57.5 -> 57 Inexact Rounded 204ddintx233 tointegralx -55.5 -> -55 Inexact Rounded 205ddintx234 tointegralx -56.5 -> -56 Inexact Rounded 206ddintx235 tointegralx -57.5 -> -57 Inexact Rounded 207 208rounding: up 209 210ddintx240 tointegralx 55.3 -> 56 Inexact Rounded 211ddintx241 tointegralx 56.3 -> 57 Inexact Rounded 212ddintx242 tointegralx 57.3 -> 58 Inexact Rounded 213ddintx243 tointegralx -55.3 -> -56 Inexact Rounded 214ddintx244 tointegralx -56.3 -> -57 Inexact Rounded 215ddintx245 tointegralx -57.3 -> -58 Inexact Rounded 216 217rounding: down 218 219ddintx250 tointegralx 55.7 -> 55 Inexact Rounded 220ddintx251 tointegralx 56.7 -> 56 Inexact Rounded 221ddintx252 tointegralx 57.7 -> 57 Inexact Rounded 222ddintx253 tointegralx -55.7 -> -55 Inexact Rounded 223ddintx254 tointegralx -56.7 -> -56 Inexact Rounded 224ddintx255 tointegralx -57.7 -> -57 Inexact Rounded 225 226rounding: ceiling 227 228ddintx260 tointegralx 55.3 -> 56 Inexact Rounded 229ddintx261 tointegralx 56.3 -> 57 Inexact Rounded 230ddintx262 tointegralx 57.3 -> 58 Inexact Rounded 231ddintx263 tointegralx -55.3 -> -55 Inexact Rounded 232ddintx264 tointegralx -56.3 -> -56 Inexact Rounded 233ddintx265 tointegralx -57.3 -> -57 Inexact Rounded 234 235rounding: floor 236 237ddintx270 tointegralx 55.7 -> 55 Inexact Rounded 238ddintx271 tointegralx 56.7 -> 56 Inexact Rounded 239ddintx272 tointegralx 57.7 -> 57 Inexact Rounded 240ddintx273 tointegralx -55.7 -> -56 Inexact Rounded 241ddintx274 tointegralx -56.7 -> -57 Inexact Rounded 242ddintx275 tointegralx -57.7 -> -58 Inexact Rounded 243 244-- Int and uInt32 edge values for testing conversions 245ddintx300 tointegralx -2147483646 -> -2147483646 246ddintx301 tointegralx -2147483647 -> -2147483647 247ddintx302 tointegralx -2147483648 -> -2147483648 248ddintx303 tointegralx -2147483649 -> -2147483649 249ddintx304 tointegralx 2147483646 -> 2147483646 250ddintx305 tointegralx 2147483647 -> 2147483647 251ddintx306 tointegralx 2147483648 -> 2147483648 252ddintx307 tointegralx 2147483649 -> 2147483649 253ddintx308 tointegralx 4294967294 -> 4294967294 254ddintx309 tointegralx 4294967295 -> 4294967295 255ddintx310 tointegralx 4294967296 -> 4294967296 256ddintx311 tointegralx 4294967297 -> 4294967297 257 258