cpython/Lib/test/decimaltestdata/normalize.decTest

226 lines
9.3 KiB
Plaintext
Raw Normal View History

------------------------------------------------------------------------
-- normalize.decTest -- remove trailing zeros --
-- Copyright (c) IBM Corporation, 2003. All rights reserved. --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases" --
-- at http://www2.hursley.ibm.com/decimal for the description of --
-- these testcases. --
-- --
-- These testcases are experimental ('beta' versions), and they --
-- may contain errors. They are offered on an as-is basis. In --
-- particular, achieving the same results as the tests here is not --
-- a guarantee that an implementation complies with any Standard --
-- or specification. The tests are not exhaustive. --
-- --
-- Please send comments, suggestions, and corrections to the author: --
-- Mike Cowlishaw, IBM Fellow --
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
-- mfc@uk.ibm.com --
------------------------------------------------------------------------
version: 2.39
extended: 1
precision: 9
rounding: half_up
maxExponent: 999
minexponent: -999
nrmx001 normalize '1' -> '1'
nrmx002 normalize '-1' -> '-1'
nrmx003 normalize '1.00' -> '1'
nrmx004 normalize '-1.00' -> '-1'
nrmx005 normalize '0' -> '0'
nrmx006 normalize '0.00' -> '0'
nrmx007 normalize '00.0' -> '0'
nrmx008 normalize '00.00' -> '0'
nrmx009 normalize '00' -> '0'
nrmx010 normalize '0E+1' -> '0'
nrmx011 normalize '0E+5' -> '0'
nrmx012 normalize '-2' -> '-2'
nrmx013 normalize '2' -> '2'
nrmx014 normalize '-2.00' -> '-2'
nrmx015 normalize '2.00' -> '2'
nrmx016 normalize '-0' -> '-0'
nrmx017 normalize '-0.00' -> '-0'
nrmx018 normalize '-00.0' -> '-0'
nrmx019 normalize '-00.00' -> '-0'
nrmx020 normalize '-00' -> '-0'
nrmx021 normalize '-0E+5' -> '-0'
nrmx022 normalize '-0E+1' -> '-0'
nrmx030 normalize '+0.1' -> '0.1'
nrmx031 normalize '-0.1' -> '-0.1'
nrmx032 normalize '+0.01' -> '0.01'
nrmx033 normalize '-0.01' -> '-0.01'
nrmx034 normalize '+0.001' -> '0.001'
nrmx035 normalize '-0.001' -> '-0.001'
nrmx036 normalize '+0.000001' -> '0.000001'
nrmx037 normalize '-0.000001' -> '-0.000001'
nrmx038 normalize '+0.000000000001' -> '1E-12'
nrmx039 normalize '-0.000000000001' -> '-1E-12'
nrmx041 normalize 1.1 -> 1.1
nrmx042 normalize 1.10 -> 1.1
nrmx043 normalize 1.100 -> 1.1
nrmx044 normalize 1.110 -> 1.11
nrmx045 normalize -1.1 -> -1.1
nrmx046 normalize -1.10 -> -1.1
nrmx047 normalize -1.100 -> -1.1
nrmx048 normalize -1.110 -> -1.11
nrmx049 normalize 9.9 -> 9.9
nrmx050 normalize 9.90 -> 9.9
nrmx051 normalize 9.900 -> 9.9
nrmx052 normalize 9.990 -> 9.99
nrmx053 normalize -9.9 -> -9.9
nrmx054 normalize -9.90 -> -9.9
nrmx055 normalize -9.900 -> -9.9
nrmx056 normalize -9.990 -> -9.99
-- some trailing fractional zeros with zeros in units
nrmx060 normalize 10.0 -> 1E+1
nrmx061 normalize 10.00 -> 1E+1
nrmx062 normalize 100.0 -> 1E+2
nrmx063 normalize 100.00 -> 1E+2
nrmx064 normalize 1.1000E+3 -> 1.1E+3
nrmx065 normalize 1.10000E+3 -> 1.1E+3
nrmx066 normalize -10.0 -> -1E+1
nrmx067 normalize -10.00 -> -1E+1
nrmx068 normalize -100.0 -> -1E+2
nrmx069 normalize -100.00 -> -1E+2
nrmx070 normalize -1.1000E+3 -> -1.1E+3
nrmx071 normalize -1.10000E+3 -> -1.1E+3
-- some insignificant trailing zeros with positive exponent
nrmx080 normalize 10E+1 -> 1E+2
nrmx081 normalize 100E+1 -> 1E+3
nrmx082 normalize 1.0E+2 -> 1E+2
nrmx083 normalize 1.0E+3 -> 1E+3
nrmx084 normalize 1.1E+3 -> 1.1E+3
nrmx085 normalize 1.00E+3 -> 1E+3
nrmx086 normalize 1.10E+3 -> 1.1E+3
nrmx087 normalize -10E+1 -> -1E+2
nrmx088 normalize -100E+1 -> -1E+3
nrmx089 normalize -1.0E+2 -> -1E+2
nrmx090 normalize -1.0E+3 -> -1E+3
nrmx091 normalize -1.1E+3 -> -1.1E+3
nrmx092 normalize -1.00E+3 -> -1E+3
nrmx093 normalize -1.10E+3 -> -1.1E+3
-- some significant trailing zeros, were we to be trimming
nrmx100 normalize 11 -> 11
nrmx101 normalize 10 -> 1E+1
nrmx102 normalize 10. -> 1E+1
nrmx103 normalize 1.1E+1 -> 11
nrmx104 normalize 1.0E+1 -> 1E+1
nrmx105 normalize 1.10E+2 -> 1.1E+2
nrmx106 normalize 1.00E+2 -> 1E+2
nrmx107 normalize 1.100E+3 -> 1.1E+3
nrmx108 normalize 1.000E+3 -> 1E+3
nrmx109 normalize 1.000000E+6 -> 1E+6
nrmx110 normalize -11 -> -11
nrmx111 normalize -10 -> -1E+1
nrmx112 normalize -10. -> -1E+1
nrmx113 normalize -1.1E+1 -> -11
nrmx114 normalize -1.0E+1 -> -1E+1
nrmx115 normalize -1.10E+2 -> -1.1E+2
nrmx116 normalize -1.00E+2 -> -1E+2
nrmx117 normalize -1.100E+3 -> -1.1E+3
nrmx118 normalize -1.000E+3 -> -1E+3
nrmx119 normalize -1.00000E+5 -> -1E+5
nrmx120 normalize -1.000000E+6 -> -1E+6
nrmx121 normalize -10.00000E+6 -> -1E+7
nrmx122 normalize -100.0000E+6 -> -1E+8
nrmx123 normalize -1000.000E+6 -> -1E+9
nrmx124 normalize -10000.00E+6 -> -1E+10
nrmx125 normalize -100000.0E+6 -> -1E+11
nrmx126 normalize -1000000.E+6 -> -1E+12
-- examples from decArith
nrmx140 normalize '2.1' -> '2.1'
nrmx141 normalize '-2.0' -> '-2'
nrmx142 normalize '1.200' -> '1.2'
nrmx143 normalize '-120' -> '-1.2E+2'
nrmx144 normalize '120.00' -> '1.2E+2'
nrmx145 normalize '0.00' -> '0'
-- overflow tests
maxexponent: 999999999
minexponent: -999999999
precision: 3
nrmx160 normalize 9.999E+999999999 -> Infinity Inexact Overflow Rounded
nrmx161 normalize -9.999E+999999999 -> -Infinity Inexact Overflow Rounded
-- subnormals and underflow
precision: 3
maxexponent: 999
minexponent: -999
nrmx210 normalize 1.00E-999 -> 1E-999
nrmx211 normalize 0.1E-999 -> 1E-1000 Subnormal
nrmx212 normalize 0.10E-999 -> 1E-1000 Subnormal
nrmx213 normalize 0.100E-999 -> 1E-1000 Subnormal Rounded
nrmx214 normalize 0.01E-999 -> 1E-1001 Subnormal
-- next is rounded to Emin
nrmx215 normalize 0.999E-999 -> 1E-999 Inexact Rounded Subnormal Underflow
nrmx216 normalize 0.099E-999 -> 1E-1000 Inexact Rounded Subnormal Underflow
nrmx217 normalize 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
nrmx218 normalize 0.001E-999 -> 0 Inexact Rounded Subnormal Underflow
nrmx219 normalize 0.0009E-999 -> 0 Inexact Rounded Subnormal Underflow
nrmx220 normalize 0.0001E-999 -> 0 Inexact Rounded Subnormal Underflow
nrmx230 normalize -1.00E-999 -> -1E-999
nrmx231 normalize -0.1E-999 -> -1E-1000 Subnormal
nrmx232 normalize -0.10E-999 -> -1E-1000 Subnormal
nrmx233 normalize -0.100E-999 -> -1E-1000 Subnormal Rounded
nrmx234 normalize -0.01E-999 -> -1E-1001 Subnormal
-- next is rounded to Emin
nrmx235 normalize -0.999E-999 -> -1E-999 Inexact Rounded Subnormal Underflow
nrmx236 normalize -0.099E-999 -> -1E-1000 Inexact Rounded Subnormal Underflow
nrmx237 normalize -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow
nrmx238 normalize -0.001E-999 -> -0 Inexact Rounded Subnormal Underflow
nrmx239 normalize -0.0009E-999 -> -0 Inexact Rounded Subnormal Underflow
nrmx240 normalize -0.0001E-999 -> -0 Inexact Rounded Subnormal Underflow
-- more reshaping
precision: 9
nrmx260 normalize '56260E-10' -> '0.000005626'
nrmx261 normalize '56260E-5' -> '0.5626'
nrmx262 normalize '56260E-2' -> '562.6'
nrmx263 normalize '56260E-1' -> '5626'
nrmx265 normalize '56260E-0' -> '5.626E+4'
nrmx266 normalize '56260E+0' -> '5.626E+4'
nrmx267 normalize '56260E+1' -> '5.626E+5'
nrmx268 normalize '56260E+2' -> '5.626E+6'
nrmx269 normalize '56260E+3' -> '5.626E+7'
nrmx270 normalize '56260E+4' -> '5.626E+8'
nrmx271 normalize '56260E+5' -> '5.626E+9'
nrmx272 normalize '56260E+6' -> '5.626E+10'
nrmx280 normalize '-56260E-10' -> '-0.000005626'
nrmx281 normalize '-56260E-5' -> '-0.5626'
nrmx282 normalize '-56260E-2' -> '-562.6'
nrmx283 normalize '-56260E-1' -> '-5626'
nrmx285 normalize '-56260E-0' -> '-5.626E+4'
nrmx286 normalize '-56260E+0' -> '-5.626E+4'
nrmx287 normalize '-56260E+1' -> '-5.626E+5'
nrmx288 normalize '-56260E+2' -> '-5.626E+6'
nrmx289 normalize '-56260E+3' -> '-5.626E+7'
nrmx290 normalize '-56260E+4' -> '-5.626E+8'
nrmx291 normalize '-56260E+5' -> '-5.626E+9'
nrmx292 normalize '-56260E+6' -> '-5.626E+10'
-- specials
nrmx820 normalize 'Inf' -> 'Infinity'
nrmx821 normalize '-Inf' -> '-Infinity'
nrmx822 normalize NaN -> NaN
nrmx823 normalize sNaN -> NaN Invalid_operation
nrmx824 normalize NaN101 -> NaN101
nrmx825 normalize sNaN010 -> NaN10 Invalid_operation
nrmx827 normalize -NaN -> -NaN
nrmx828 normalize -sNaN -> -NaN Invalid_operation
nrmx829 normalize -NaN101 -> -NaN101
nrmx830 normalize -sNaN010 -> -NaN10 Invalid_operation
-- Null test
nrmx900 normalize # -> NaN Invalid_operation