From 1d7c94e1c19be70ae480c3bdc6afcf6aca527422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Baru=C4=8Di=C4=87?= Date: Sun, 20 Oct 2024 19:44:57 +0200 Subject: [PATCH] Context This commit introduces `Context`, a structure that holds configuration of the decimal arithmetics. Eventually, the global variable `DIGITS` should be completely removed in favor of this newly-added structure. --- src/Decimals.jl | 1 + src/arithmetic.jl | 6 +- src/bigint.jl | 2 + src/context.jl | 106 ++++ test/dectests/test_compare.jl | 1127 +++++++++++++++++++++++++++++++++ test/dectests/test_minus.jl | 227 +++++++ test/dectests/test_plus.jl | 249 ++++++++ test/runtests.jl | 9 +- test/test_compare.jl | 827 ------------------------ test/test_context.jl | 12 + 10 files changed, 1732 insertions(+), 834 deletions(-) create mode 100644 src/context.jl create mode 100644 test/dectests/test_compare.jl create mode 100644 test/dectests/test_minus.jl create mode 100644 test/dectests/test_plus.jl delete mode 100644 test/test_compare.jl create mode 100644 test/test_context.jl diff --git a/src/Decimals.jl b/src/Decimals.jl index 2160794..7e8ab6c 100644 --- a/src/Decimals.jl +++ b/src/Decimals.jl @@ -21,6 +21,7 @@ struct Decimal <: AbstractFloat end include("bigint.jl") +include("context.jl") # Convert between Decimal objects, numbers, and strings include("decimal.jl") diff --git a/src/arithmetic.jl b/src/arithmetic.jl index 549c10b..a8f1289 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -4,7 +4,8 @@ Base.promote_rule(::Type{Decimal}, ::Type{<:Real}) = Decimal Base.promote_rule(::Type{BigFloat}, ::Type{Decimal}) = Decimal Base.promote_rule(::Type{BigInt}, ::Type{Decimal}) = Decimal -const BigTen = BigInt(10) +Base.:(+)(x::Decimal) = fix(x) +Base.:(-)(x::Decimal) = fix(Decimal(!x.s, x.c, x.q)) # Addition # To add, convert both decimals to the same exponent. @@ -24,9 +25,6 @@ function Base.:(+)(x::Decimal, y::Decimal) return normalize(Decimal(s, abs(c), y.q)) end -# Negation -Base.:(-)(x::Decimal) = Decimal(!x.s, x.c, x.q) - # Subtraction Base.:(-)(x::Decimal, y::Decimal) = +(x, -y) diff --git a/src/bigint.jl b/src/bigint.jl index 08d8827..f270247 100644 --- a/src/bigint.jl +++ b/src/bigint.jl @@ -4,6 +4,8 @@ else const libgmp = Base.GMP.libgmp end +const BigTen = BigInt(10) + function isdivisible(x::BigInt, n::Int) r = ccall((:__gmpz_divisible_ui_p, libgmp), Cint, (Base.GMP.MPZ.mpz_t, Culong), x, n) diff --git a/src/context.jl b/src/context.jl new file mode 100644 index 0000000..4e5a607 --- /dev/null +++ b/src/context.jl @@ -0,0 +1,106 @@ +Base.@kwdef mutable struct Context + precision::Int + rounding::RoundingMode + Emax::Int + Emin::Int +end + +const CONTEXT = Context(precision=28, + rounding=RoundNearest, + Emax=999999, + Emin=-999999) + +function Base.setprecision(::Type{Decimal}, precision::Int) + CONTEXT.precision = precision + return precision +end + +Base.precision(::Type{Decimal}) = CONTEXT.precision + +function Base.setrounding(::Type{Decimal}, rounding::RoundingMode) + CONTEXT.rounding = rounding + return rounding +end + +Base.rounding(::Type{Decimal}) = CONTEXT.rounding + +""" + fix(x) + +Round and fix the exponent of `x` to keep it within the precision and exponent +limits as given by the current `CONTEXT`. +""" +function fix(x::Decimal) + prec = precision(Decimal) + rmod = rounding(Decimal) + + Emin, Emax = CONTEXT.Emin, CONTEXT.Emax + Etiny = Emin - prec + 1 + Etop = Emax - prec + 1 + + if iszero(x) + return Decimal(x.s, x.c, clamp(x.q, Etiny, Etop)) + end + + clen = ndigits(x.c) + exp_min = clen + x.q - prec + + # Equivalent to `clen + x.q - 1 > Emax` + if exp_min > Etop + throw(OverflowError("Exponent limit ($Emax) exceeded: $x")) + end + + subnormal = exp_min < Etiny + if subnormal + exp_min = Etiny + end + + # Number of digits and exponent within bounds + if x.q ≥ exp_min + return x + end + + # Signed coefficient for rounding modes like RoundToZero + c = (-1)^x.s * x.c + q = exp_min + + # Number of digits of the resulting coefficient + digits = clen + x.q - exp_min + if digits < 0 + c = big(1) + q = exp_min - 1 + digits = 0 + end + + # Number of least significant digits to remove from `c` + trun_len = clen - digits + + # Split `c` into `digits` most significant digits and `trun_len` least + # significant digits + # This is like round(c, rmod, sigdigits=digits), except here we can + # tell from `rem` if the rounding was lossless + c, rem = divrem(c, BigTen ^ trun_len, rmod) + + # Rounding is exact if the truncated digits were zero + exact = iszero(rem) + + # If the number of digits exceeded `digits` after rounding, + # it means that `c` was like 99...9 and was rounded up, + # becoming 100...0, so `c` is divisible by 10 + if ndigits(c) > prec + c = exactdiv(c, 10) + q += 1 + end + + # Exponent might have exceeded due to rounding + if q > Etop + throw(OverflowError("Exponent limit ($Emax) exceeded: $x")) + end + + #if subnormal && !exact + # throw(ErrorException("Underflow")) + #end + + return Decimal(signbit(c), abs(c), q) +end + diff --git a/test/dectests/test_compare.jl b/test/dectests/test_compare.jl new file mode 100644 index 0000000..a39590a --- /dev/null +++ b/test/dectests/test_compare.jl @@ -0,0 +1,1127 @@ +using Decimals +using Test + +@testset "Compare" begin + setprecision(Decimal, 9) + setrounding(Decimal, RoundNearestTiesAway) + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + # comx001 + @test cmp(dec"-2", dec"-2") == dec"0" + # comx002 + @test cmp(dec"-2", dec"-1") == dec"-1" + # comx003 + @test cmp(dec"-2", dec"0") == dec"-1" + # comx004 + @test cmp(dec"-2", dec"1") == dec"-1" + # comx005 + @test cmp(dec"-2", dec"2") == dec"-1" + # comx006 + @test cmp(dec"-1", dec"-2") == dec"1" + # comx007 + @test cmp(dec"-1", dec"-1") == dec"0" + # comx008 + @test cmp(dec"-1", dec"0") == dec"-1" + # comx009 + @test cmp(dec"-1", dec"1") == dec"-1" + # comx010 + @test cmp(dec"-1", dec"2") == dec"-1" + # comx011 + @test cmp(dec"0", dec"-2") == dec"1" + # comx012 + @test cmp(dec"0", dec"-1") == dec"1" + # comx013 + @test cmp(dec"0", dec"0") == dec"0" + # comx014 + @test cmp(dec"0", dec"1") == dec"-1" + # comx015 + @test cmp(dec"0", dec"2") == dec"-1" + # comx016 + @test cmp(dec"1", dec"-2") == dec"1" + # comx017 + @test cmp(dec"1", dec"-1") == dec"1" + # comx018 + @test cmp(dec"1", dec"0") == dec"1" + # comx019 + @test cmp(dec"1", dec"1") == dec"0" + # comx020 + @test cmp(dec"1", dec"2") == dec"-1" + # comx021 + @test cmp(dec"2", dec"-2") == dec"1" + # comx022 + @test cmp(dec"2", dec"-1") == dec"1" + # comx023 + @test cmp(dec"2", dec"0") == dec"1" + # comx025 + @test cmp(dec"2", dec"1") == dec"1" + # comx026 + @test cmp(dec"2", dec"2") == dec"0" + # comx031 + @test cmp(dec"-20", dec"-20") == dec"0" + # comx032 + @test cmp(dec"-20", dec"-10") == dec"-1" + # comx033 + @test cmp(dec"-20", dec"00") == dec"-1" + # comx034 + @test cmp(dec"-20", dec"10") == dec"-1" + # comx035 + @test cmp(dec"-20", dec"20") == dec"-1" + # comx036 + @test cmp(dec"-10", dec"-20") == dec"1" + # comx037 + @test cmp(dec"-10", dec"-10") == dec"0" + # comx038 + @test cmp(dec"-10", dec"00") == dec"-1" + # comx039 + @test cmp(dec"-10", dec"10") == dec"-1" + # comx040 + @test cmp(dec"-10", dec"20") == dec"-1" + # comx041 + @test cmp(dec"00", dec"-20") == dec"1" + # comx042 + @test cmp(dec"00", dec"-10") == dec"1" + # comx043 + @test cmp(dec"00", dec"00") == dec"0" + # comx044 + @test cmp(dec"00", dec"10") == dec"-1" + # comx045 + @test cmp(dec"00", dec"20") == dec"-1" + # comx046 + @test cmp(dec"10", dec"-20") == dec"1" + # comx047 + @test cmp(dec"10", dec"-10") == dec"1" + # comx048 + @test cmp(dec"10", dec"00") == dec"1" + # comx049 + @test cmp(dec"10", dec"10") == dec"0" + # comx050 + @test cmp(dec"10", dec"20") == dec"-1" + # comx051 + @test cmp(dec"20", dec"-20") == dec"1" + # comx052 + @test cmp(dec"20", dec"-10") == dec"1" + # comx053 + @test cmp(dec"20", dec"00") == dec"1" + # comx055 + @test cmp(dec"20", dec"10") == dec"1" + # comx056 + @test cmp(dec"20", dec"20") == dec"0" + # comx061 + @test cmp(dec"-2.0", dec"-2.0") == dec"0" + # comx062 + @test cmp(dec"-2.0", dec"-1.0") == dec"-1" + # comx063 + @test cmp(dec"-2.0", dec"0.0") == dec"-1" + # comx064 + @test cmp(dec"-2.0", dec"1.0") == dec"-1" + # comx065 + @test cmp(dec"-2.0", dec"2.0") == dec"-1" + # comx066 + @test cmp(dec"-1.0", dec"-2.0") == dec"1" + # comx067 + @test cmp(dec"-1.0", dec"-1.0") == dec"0" + # comx068 + @test cmp(dec"-1.0", dec"0.0") == dec"-1" + # comx069 + @test cmp(dec"-1.0", dec"1.0") == dec"-1" + # comx070 + @test cmp(dec"-1.0", dec"2.0") == dec"-1" + # comx071 + @test cmp(dec"0.0", dec"-2.0") == dec"1" + # comx072 + @test cmp(dec"0.0", dec"-1.0") == dec"1" + # comx073 + @test cmp(dec"0.0", dec"0.0") == dec"0" + # comx074 + @test cmp(dec"0.0", dec"1.0") == dec"-1" + # comx075 + @test cmp(dec"0.0", dec"2.0") == dec"-1" + # comx076 + @test cmp(dec"1.0", dec"-2.0") == dec"1" + # comx077 + @test cmp(dec"1.0", dec"-1.0") == dec"1" + # comx078 + @test cmp(dec"1.0", dec"0.0") == dec"1" + # comx079 + @test cmp(dec"1.0", dec"1.0") == dec"0" + # comx080 + @test cmp(dec"1.0", dec"2.0") == dec"-1" + # comx081 + @test cmp(dec"2.0", dec"-2.0") == dec"1" + # comx082 + @test cmp(dec"2.0", dec"-1.0") == dec"1" + # comx083 + @test cmp(dec"2.0", dec"0.0") == dec"1" + # comx085 + @test cmp(dec"2.0", dec"1.0") == dec"1" + # comx086 + @test cmp(dec"2.0", dec"2.0") == dec"0" + Decimals.CONTEXT.Emax = 999999999 + Decimals.CONTEXT.Emin = -999999999 + # comx095 + @test cmp(dec"9.99999999e+999999999", dec"9.99999999e+999999999") == dec"0" + # comx096 + @test cmp(dec"-9.99999999e+999999999", dec"9.99999999e+999999999") == dec"-1" + # comx097 + @test cmp(dec"9.99999999e+999999999", dec"-9.99999999e+999999999") == dec"1" + # comx098 + @test cmp(dec"-9.99999999e+999999999", dec"-9.99999999e+999999999") == dec"0" + # comx100 + @test cmp(dec"7.0", dec"7.0") == dec"0" + # comx101 + @test cmp(dec"7.0", dec"7") == dec"0" + # comx102 + @test cmp(dec"7", dec"7.0") == dec"0" + # comx103 + @test cmp(dec"7e+0", dec"7.0") == dec"0" + # comx104 + @test cmp(dec"70e-1", dec"7.0") == dec"0" + # comx105 + @test cmp(dec"0.7e+1", dec"7") == dec"0" + # comx106 + @test cmp(dec"70e-1", dec"7") == dec"0" + # comx107 + @test cmp(dec"7.0", dec"7e+0") == dec"0" + # comx108 + @test cmp(dec"7.0", dec"70e-1") == dec"0" + # comx109 + @test cmp(dec"7", dec"0.7e+1") == dec"0" + # comx110 + @test cmp(dec"7", dec"70e-1") == dec"0" + # comx120 + @test cmp(dec"8.0", dec"7.0") == dec"1" + # comx121 + @test cmp(dec"8.0", dec"7") == dec"1" + # comx122 + @test cmp(dec"8", dec"7.0") == dec"1" + # comx123 + @test cmp(dec"8e+0", dec"7.0") == dec"1" + # comx124 + @test cmp(dec"80e-1", dec"7.0") == dec"1" + # comx125 + @test cmp(dec"0.8e+1", dec"7") == dec"1" + # comx126 + @test cmp(dec"80e-1", dec"7") == dec"1" + # comx127 + @test cmp(dec"8.0", dec"7e+0") == dec"1" + # comx128 + @test cmp(dec"8.0", dec"70e-1") == dec"1" + # comx129 + @test cmp(dec"8", dec"0.7e+1") == dec"1" + # comx130 + @test cmp(dec"8", dec"70e-1") == dec"1" + # comx140 + @test cmp(dec"8.0", dec"9.0") == dec"-1" + # comx141 + @test cmp(dec"8.0", dec"9") == dec"-1" + # comx142 + @test cmp(dec"8", dec"9.0") == dec"-1" + # comx143 + @test cmp(dec"8e+0", dec"9.0") == dec"-1" + # comx144 + @test cmp(dec"80e-1", dec"9.0") == dec"-1" + # comx145 + @test cmp(dec"0.8e+1", dec"9") == dec"-1" + # comx146 + @test cmp(dec"80e-1", dec"9") == dec"-1" + # comx147 + @test cmp(dec"8.0", dec"9e+0") == dec"-1" + # comx148 + @test cmp(dec"8.0", dec"90e-1") == dec"-1" + # comx149 + @test cmp(dec"8", dec"0.9e+1") == dec"-1" + # comx150 + @test cmp(dec"8", dec"90e-1") == dec"-1" + # comx200 + @test cmp(dec"-7.0", dec"7.0") == dec"-1" + # comx201 + @test cmp(dec"-7.0", dec"7") == dec"-1" + # comx202 + @test cmp(dec"-7", dec"7.0") == dec"-1" + # comx203 + @test cmp(dec"-7e+0", dec"7.0") == dec"-1" + # comx204 + @test cmp(dec"-70e-1", dec"7.0") == dec"-1" + # comx205 + @test cmp(dec"-0.7e+1", dec"7") == dec"-1" + # comx206 + @test cmp(dec"-70e-1", dec"7") == dec"-1" + # comx207 + @test cmp(dec"-7.0", dec"7e+0") == dec"-1" + # comx208 + @test cmp(dec"-7.0", dec"70e-1") == dec"-1" + # comx209 + @test cmp(dec"-7", dec"0.7e+1") == dec"-1" + # comx210 + @test cmp(dec"-7", dec"70e-1") == dec"-1" + # comx220 + @test cmp(dec"-8.0", dec"7.0") == dec"-1" + # comx221 + @test cmp(dec"-8.0", dec"7") == dec"-1" + # comx222 + @test cmp(dec"-8", dec"7.0") == dec"-1" + # comx223 + @test cmp(dec"-8e+0", dec"7.0") == dec"-1" + # comx224 + @test cmp(dec"-80e-1", dec"7.0") == dec"-1" + # comx225 + @test cmp(dec"-0.8e+1", dec"7") == dec"-1" + # comx226 + @test cmp(dec"-80e-1", dec"7") == dec"-1" + # comx227 + @test cmp(dec"-8.0", dec"7e+0") == dec"-1" + # comx228 + @test cmp(dec"-8.0", dec"70e-1") == dec"-1" + # comx229 + @test cmp(dec"-8", dec"0.7e+1") == dec"-1" + # comx230 + @test cmp(dec"-8", dec"70e-1") == dec"-1" + # comx240 + @test cmp(dec"-8.0", dec"9.0") == dec"-1" + # comx241 + @test cmp(dec"-8.0", dec"9") == dec"-1" + # comx242 + @test cmp(dec"-8", dec"9.0") == dec"-1" + # comx243 + @test cmp(dec"-8e+0", dec"9.0") == dec"-1" + # comx244 + @test cmp(dec"-80e-1", dec"9.0") == dec"-1" + # comx245 + @test cmp(dec"-0.8e+1", dec"9") == dec"-1" + # comx246 + @test cmp(dec"-80e-1", dec"9") == dec"-1" + # comx247 + @test cmp(dec"-8.0", dec"9e+0") == dec"-1" + # comx248 + @test cmp(dec"-8.0", dec"90e-1") == dec"-1" + # comx249 + @test cmp(dec"-8", dec"0.9e+1") == dec"-1" + # comx250 + @test cmp(dec"-8", dec"90e-1") == dec"-1" + # comx300 + @test cmp(dec"7.0", dec"-7.0") == dec"1" + # comx301 + @test cmp(dec"7.0", dec"-7") == dec"1" + # comx302 + @test cmp(dec"7", dec"-7.0") == dec"1" + # comx303 + @test cmp(dec"7e+0", dec"-7.0") == dec"1" + # comx304 + @test cmp(dec"70e-1", dec"-7.0") == dec"1" + # comx305 + @test cmp(dec".7e+1", dec"-7") == dec"1" + # comx306 + @test cmp(dec"70e-1", dec"-7") == dec"1" + # comx307 + @test cmp(dec"7.0", dec"-7e+0") == dec"1" + # comx308 + @test cmp(dec"7.0", dec"-70e-1") == dec"1" + # comx309 + @test cmp(dec"7", dec"-.7e+1") == dec"1" + # comx310 + @test cmp(dec"7", dec"-70e-1") == dec"1" + # comx320 + @test cmp(dec"8.0", dec"-7.0") == dec"1" + # comx321 + @test cmp(dec"8.0", dec"-7") == dec"1" + # comx322 + @test cmp(dec"8", dec"-7.0") == dec"1" + # comx323 + @test cmp(dec"8e+0", dec"-7.0") == dec"1" + # comx324 + @test cmp(dec"80e-1", dec"-7.0") == dec"1" + # comx325 + @test cmp(dec".8e+1", dec"-7") == dec"1" + # comx326 + @test cmp(dec"80e-1", dec"-7") == dec"1" + # comx327 + @test cmp(dec"8.0", dec"-7e+0") == dec"1" + # comx328 + @test cmp(dec"8.0", dec"-70e-1") == dec"1" + # comx329 + @test cmp(dec"8", dec"-.7e+1") == dec"1" + # comx330 + @test cmp(dec"8", dec"-70e-1") == dec"1" + # comx340 + @test cmp(dec"8.0", dec"-9.0") == dec"1" + # comx341 + @test cmp(dec"8.0", dec"-9") == dec"1" + # comx342 + @test cmp(dec"8", dec"-9.0") == dec"1" + # comx343 + @test cmp(dec"8e+0", dec"-9.0") == dec"1" + # comx344 + @test cmp(dec"80e-1", dec"-9.0") == dec"1" + # comx345 + @test cmp(dec".8e+1", dec"-9") == dec"1" + # comx346 + @test cmp(dec"80e-1", dec"-9") == dec"1" + # comx347 + @test cmp(dec"8.0", dec"-9e+0") == dec"1" + # comx348 + @test cmp(dec"8.0", dec"-90e-1") == dec"1" + # comx349 + @test cmp(dec"8", dec"-.9e+1") == dec"1" + # comx350 + @test cmp(dec"8", dec"-90e-1") == dec"1" + # comx400 + @test cmp(dec"-7.0", dec"-7.0") == dec"0" + # comx401 + @test cmp(dec"-7.0", dec"-7") == dec"0" + # comx402 + @test cmp(dec"-7", dec"-7.0") == dec"0" + # comx403 + @test cmp(dec"-7e+0", dec"-7.0") == dec"0" + # comx404 + @test cmp(dec"-70e-1", dec"-7.0") == dec"0" + # comx405 + @test cmp(dec"-.7e+1", dec"-7") == dec"0" + # comx406 + @test cmp(dec"-70e-1", dec"-7") == dec"0" + # comx407 + @test cmp(dec"-7.0", dec"-7e+0") == dec"0" + # comx408 + @test cmp(dec"-7.0", dec"-70e-1") == dec"0" + # comx409 + @test cmp(dec"-7", dec"-.7e+1") == dec"0" + # comx410 + @test cmp(dec"-7", dec"-70e-1") == dec"0" + # comx420 + @test cmp(dec"-8.0", dec"-7.0") == dec"-1" + # comx421 + @test cmp(dec"-8.0", dec"-7") == dec"-1" + # comx422 + @test cmp(dec"-8", dec"-7.0") == dec"-1" + # comx423 + @test cmp(dec"-8e+0", dec"-7.0") == dec"-1" + # comx424 + @test cmp(dec"-80e-1", dec"-7.0") == dec"-1" + # comx425 + @test cmp(dec"-.8e+1", dec"-7") == dec"-1" + # comx426 + @test cmp(dec"-80e-1", dec"-7") == dec"-1" + # comx427 + @test cmp(dec"-8.0", dec"-7e+0") == dec"-1" + # comx428 + @test cmp(dec"-8.0", dec"-70e-1") == dec"-1" + # comx429 + @test cmp(dec"-8", dec"-.7e+1") == dec"-1" + # comx430 + @test cmp(dec"-8", dec"-70e-1") == dec"-1" + # comx440 + @test cmp(dec"-8.0", dec"-9.0") == dec"1" + # comx441 + @test cmp(dec"-8.0", dec"-9") == dec"1" + # comx442 + @test cmp(dec"-8", dec"-9.0") == dec"1" + # comx443 + @test cmp(dec"-8e+0", dec"-9.0") == dec"1" + # comx444 + @test cmp(dec"-80e-1", dec"-9.0") == dec"1" + # comx445 + @test cmp(dec"-.8e+1", dec"-9") == dec"1" + # comx446 + @test cmp(dec"-80e-1", dec"-9") == dec"1" + # comx447 + @test cmp(dec"-8.0", dec"-9e+0") == dec"1" + # comx448 + @test cmp(dec"-8.0", dec"-90e-1") == dec"1" + # comx449 + @test cmp(dec"-8", dec"-.9e+1") == dec"1" + # comx450 + @test cmp(dec"-8", dec"-90e-1") == dec"1" + # comx451 + @test cmp(dec"1.0", dec"0.1") == dec"1" + # comx452 + @test cmp(dec"0.1", dec"1.0") == dec"-1" + # comx453 + @test cmp(dec"10.0", dec"0.1") == dec"1" + # comx454 + @test cmp(dec"0.1", dec"10.0") == dec"-1" + # comx455 + @test cmp(dec"100", dec"1.0") == dec"1" + # comx456 + @test cmp(dec"1.0", dec"100") == dec"-1" + # comx457 + @test cmp(dec"1000", dec"10.0") == dec"1" + # comx458 + @test cmp(dec"10.0", dec"1000") == dec"-1" + # comx459 + @test cmp(dec"10000", dec"100.0") == dec"1" + # comx460 + @test cmp(dec"100.0", dec"10000") == dec"-1" + # comx461 + @test cmp(dec"100000", dec"1000.0") == dec"1" + # comx462 + @test cmp(dec"1000.0", dec"100000") == dec"-1" + # comx463 + @test cmp(dec"1000000", dec"10000.0") == dec"1" + # comx464 + @test cmp(dec"10000.0", dec"1000000") == dec"-1" + setprecision(Decimal, 40) + # comx470 + @test cmp(dec"123.4560000000000000e789", dec"123.456e789") == dec"0" + # comx471 + @test cmp(dec"123.456000000000000e-89", dec"123.456e-89") == dec"0" + # comx472 + @test cmp(dec"123.45600000000000e789", dec"123.456e789") == dec"0" + # comx473 + @test cmp(dec"123.4560000000000e-89", dec"123.456e-89") == dec"0" + # comx474 + @test cmp(dec"123.456000000000e789", dec"123.456e789") == dec"0" + # comx475 + @test cmp(dec"123.45600000000e-89", dec"123.456e-89") == dec"0" + # comx476 + @test cmp(dec"123.4560000000e789", dec"123.456e789") == dec"0" + # comx477 + @test cmp(dec"123.456000000e-89", dec"123.456e-89") == dec"0" + # comx478 + @test cmp(dec"123.45600000e789", dec"123.456e789") == dec"0" + # comx479 + @test cmp(dec"123.4560000e-89", dec"123.456e-89") == dec"0" + # comx480 + @test cmp(dec"123.456000e789", dec"123.456e789") == dec"0" + # comx481 + @test cmp(dec"123.45600e-89", dec"123.456e-89") == dec"0" + # comx482 + @test cmp(dec"123.4560e789", dec"123.456e789") == dec"0" + # comx483 + @test cmp(dec"123.456e-89", dec"123.456e-89") == dec"0" + # comx484 + @test cmp(dec"123.456e-89", dec"123.4560000000000000e-89") == dec"0" + # comx485 + @test cmp(dec"123.456e789", dec"123.456000000000000e789") == dec"0" + # comx486 + @test cmp(dec"123.456e-89", dec"123.45600000000000e-89") == dec"0" + # comx487 + @test cmp(dec"123.456e789", dec"123.4560000000000e789") == dec"0" + # comx488 + @test cmp(dec"123.456e-89", dec"123.456000000000e-89") == dec"0" + # comx489 + @test cmp(dec"123.456e789", dec"123.45600000000e789") == dec"0" + # comx490 + @test cmp(dec"123.456e-89", dec"123.4560000000e-89") == dec"0" + # comx491 + @test cmp(dec"123.456e789", dec"123.456000000e789") == dec"0" + # comx492 + @test cmp(dec"123.456e-89", dec"123.45600000e-89") == dec"0" + # comx493 + @test cmp(dec"123.456e789", dec"123.4560000e789") == dec"0" + # comx494 + @test cmp(dec"123.456e-89", dec"123.456000e-89") == dec"0" + # comx495 + @test cmp(dec"123.456e789", dec"123.45600e789") == dec"0" + # comx496 + @test cmp(dec"123.456e-89", dec"123.4560e-89") == dec"0" + # comx497 + @test cmp(dec"123.456e789", dec"123.456e789") == dec"0" + setprecision(Decimal, 9) + # comx500 + @test cmp(dec"1", dec"1e-15") == dec"1" + # comx501 + @test cmp(dec"1", dec"1e-14") == dec"1" + # comx502 + @test cmp(dec"1", dec"1e-13") == dec"1" + # comx503 + @test cmp(dec"1", dec"1e-12") == dec"1" + # comx504 + @test cmp(dec"1", dec"1e-11") == dec"1" + # comx505 + @test cmp(dec"1", dec"1e-10") == dec"1" + # comx506 + @test cmp(dec"1", dec"1e-9") == dec"1" + # comx507 + @test cmp(dec"1", dec"1e-8") == dec"1" + # comx508 + @test cmp(dec"1", dec"1e-7") == dec"1" + # comx509 + @test cmp(dec"1", dec"1e-6") == dec"1" + # comx510 + @test cmp(dec"1", dec"1e-5") == dec"1" + # comx511 + @test cmp(dec"1", dec"1e-4") == dec"1" + # comx512 + @test cmp(dec"1", dec"1e-3") == dec"1" + # comx513 + @test cmp(dec"1", dec"1e-2") == dec"1" + # comx514 + @test cmp(dec"1", dec"1e-1") == dec"1" + # comx515 + @test cmp(dec"1", dec"1e-0") == dec"0" + # comx516 + @test cmp(dec"1", dec"1e+1") == dec"-1" + # comx517 + @test cmp(dec"1", dec"1e+2") == dec"-1" + # comx518 + @test cmp(dec"1", dec"1e+3") == dec"-1" + # comx519 + @test cmp(dec"1", dec"1e+4") == dec"-1" + # comx521 + @test cmp(dec"1", dec"1e+5") == dec"-1" + # comx522 + @test cmp(dec"1", dec"1e+6") == dec"-1" + # comx523 + @test cmp(dec"1", dec"1e+7") == dec"-1" + # comx524 + @test cmp(dec"1", dec"1e+8") == dec"-1" + # comx525 + @test cmp(dec"1", dec"1e+9") == dec"-1" + # comx526 + @test cmp(dec"1", dec"1e+10") == dec"-1" + # comx527 + @test cmp(dec"1", dec"1e+11") == dec"-1" + # comx528 + @test cmp(dec"1", dec"1e+12") == dec"-1" + # comx529 + @test cmp(dec"1", dec"1e+13") == dec"-1" + # comx530 + @test cmp(dec"1", dec"1e+14") == dec"-1" + # comx531 + @test cmp(dec"1", dec"1e+15") == dec"-1" + # comx540 + @test cmp(dec"1e-15", dec"1") == dec"-1" + # comx541 + @test cmp(dec"1e-14", dec"1") == dec"-1" + # comx542 + @test cmp(dec"1e-13", dec"1") == dec"-1" + # comx543 + @test cmp(dec"1e-12", dec"1") == dec"-1" + # comx544 + @test cmp(dec"1e-11", dec"1") == dec"-1" + # comx545 + @test cmp(dec"1e-10", dec"1") == dec"-1" + # comx546 + @test cmp(dec"1e-9", dec"1") == dec"-1" + # comx547 + @test cmp(dec"1e-8", dec"1") == dec"-1" + # comx548 + @test cmp(dec"1e-7", dec"1") == dec"-1" + # comx549 + @test cmp(dec"1e-6", dec"1") == dec"-1" + # comx550 + @test cmp(dec"1e-5", dec"1") == dec"-1" + # comx551 + @test cmp(dec"1e-4", dec"1") == dec"-1" + # comx552 + @test cmp(dec"1e-3", dec"1") == dec"-1" + # comx553 + @test cmp(dec"1e-2", dec"1") == dec"-1" + # comx554 + @test cmp(dec"1e-1", dec"1") == dec"-1" + # comx555 + @test cmp(dec"1e-0", dec"1") == dec"0" + # comx556 + @test cmp(dec"1e+1", dec"1") == dec"1" + # comx557 + @test cmp(dec"1e+2", dec"1") == dec"1" + # comx558 + @test cmp(dec"1e+3", dec"1") == dec"1" + # comx559 + @test cmp(dec"1e+4", dec"1") == dec"1" + # comx561 + @test cmp(dec"1e+5", dec"1") == dec"1" + # comx562 + @test cmp(dec"1e+6", dec"1") == dec"1" + # comx563 + @test cmp(dec"1e+7", dec"1") == dec"1" + # comx564 + @test cmp(dec"1e+8", dec"1") == dec"1" + # comx565 + @test cmp(dec"1e+9", dec"1") == dec"1" + # comx566 + @test cmp(dec"1e+10", dec"1") == dec"1" + # comx567 + @test cmp(dec"1e+11", dec"1") == dec"1" + # comx568 + @test cmp(dec"1e+12", dec"1") == dec"1" + # comx569 + @test cmp(dec"1e+13", dec"1") == dec"1" + # comx570 + @test cmp(dec"1e+14", dec"1") == dec"1" + # comx571 + @test cmp(dec"1e+15", dec"1") == dec"1" + # comx580 + @test cmp(dec"0.000000987654321", dec"1e-15") == dec"1" + # comx581 + @test cmp(dec"0.000000987654321", dec"1e-14") == dec"1" + # comx582 + @test cmp(dec"0.000000987654321", dec"1e-13") == dec"1" + # comx583 + @test cmp(dec"0.000000987654321", dec"1e-12") == dec"1" + # comx584 + @test cmp(dec"0.000000987654321", dec"1e-11") == dec"1" + # comx585 + @test cmp(dec"0.000000987654321", dec"1e-10") == dec"1" + # comx586 + @test cmp(dec"0.000000987654321", dec"1e-9") == dec"1" + # comx587 + @test cmp(dec"0.000000987654321", dec"1e-8") == dec"1" + # comx588 + @test cmp(dec"0.000000987654321", dec"1e-7") == dec"1" + # comx589 + @test cmp(dec"0.000000987654321", dec"1e-6") == dec"-1" + # comx590 + @test cmp(dec"0.000000987654321", dec"1e-5") == dec"-1" + # comx591 + @test cmp(dec"0.000000987654321", dec"1e-4") == dec"-1" + # comx592 + @test cmp(dec"0.000000987654321", dec"1e-3") == dec"-1" + # comx593 + @test cmp(dec"0.000000987654321", dec"1e-2") == dec"-1" + # comx594 + @test cmp(dec"0.000000987654321", dec"1e-1") == dec"-1" + # comx595 + @test cmp(dec"0.000000987654321", dec"1e-0") == dec"-1" + # comx596 + @test cmp(dec"0.000000987654321", dec"1e+1") == dec"-1" + # comx597 + @test cmp(dec"0.000000987654321", dec"1e+2") == dec"-1" + # comx598 + @test cmp(dec"0.000000987654321", dec"1e+3") == dec"-1" + # comx599 + @test cmp(dec"0.000000987654321", dec"1e+4") == dec"-1" + setprecision(Decimal, 20) + # comx600 + @test cmp(dec"12", dec"12.2345") == dec"-1" + # comx601 + @test cmp(dec"12.0", dec"12.2345") == dec"-1" + # comx602 + @test cmp(dec"12.00", dec"12.2345") == dec"-1" + # comx603 + @test cmp(dec"12.000", dec"12.2345") == dec"-1" + # comx604 + @test cmp(dec"12.0000", dec"12.2345") == dec"-1" + # comx605 + @test cmp(dec"12.00000", dec"12.2345") == dec"-1" + # comx606 + @test cmp(dec"12.000000", dec"12.2345") == dec"-1" + # comx607 + @test cmp(dec"12.0000000", dec"12.2345") == dec"-1" + # comx608 + @test cmp(dec"12.00000000", dec"12.2345") == dec"-1" + # comx609 + @test cmp(dec"12.000000000", dec"12.2345") == dec"-1" + # comx610 + @test cmp(dec"12.1234", dec"12") == dec"1" + # comx611 + @test cmp(dec"12.1234", dec"12.0") == dec"1" + # comx612 + @test cmp(dec"12.1234", dec"12.00") == dec"1" + # comx613 + @test cmp(dec"12.1234", dec"12.000") == dec"1" + # comx614 + @test cmp(dec"12.1234", dec"12.0000") == dec"1" + # comx615 + @test cmp(dec"12.1234", dec"12.00000") == dec"1" + # comx616 + @test cmp(dec"12.1234", dec"12.000000") == dec"1" + # comx617 + @test cmp(dec"12.1234", dec"12.0000000") == dec"1" + # comx618 + @test cmp(dec"12.1234", dec"12.00000000") == dec"1" + # comx619 + @test cmp(dec"12.1234", dec"12.000000000") == dec"1" + # comx620 + @test cmp(dec"-12", dec"-12.2345") == dec"1" + # comx621 + @test cmp(dec"-12.0", dec"-12.2345") == dec"1" + # comx622 + @test cmp(dec"-12.00", dec"-12.2345") == dec"1" + # comx623 + @test cmp(dec"-12.000", dec"-12.2345") == dec"1" + # comx624 + @test cmp(dec"-12.0000", dec"-12.2345") == dec"1" + # comx625 + @test cmp(dec"-12.00000", dec"-12.2345") == dec"1" + # comx626 + @test cmp(dec"-12.000000", dec"-12.2345") == dec"1" + # comx627 + @test cmp(dec"-12.0000000", dec"-12.2345") == dec"1" + # comx628 + @test cmp(dec"-12.00000000", dec"-12.2345") == dec"1" + # comx629 + @test cmp(dec"-12.000000000", dec"-12.2345") == dec"1" + # comx630 + @test cmp(dec"-12.1234", dec"-12") == dec"-1" + # comx631 + @test cmp(dec"-12.1234", dec"-12.0") == dec"-1" + # comx632 + @test cmp(dec"-12.1234", dec"-12.00") == dec"-1" + # comx633 + @test cmp(dec"-12.1234", dec"-12.000") == dec"-1" + # comx634 + @test cmp(dec"-12.1234", dec"-12.0000") == dec"-1" + # comx635 + @test cmp(dec"-12.1234", dec"-12.00000") == dec"-1" + # comx636 + @test cmp(dec"-12.1234", dec"-12.000000") == dec"-1" + # comx637 + @test cmp(dec"-12.1234", dec"-12.0000000") == dec"-1" + # comx638 + @test cmp(dec"-12.1234", dec"-12.00000000") == dec"-1" + # comx639 + @test cmp(dec"-12.1234", dec"-12.000000000") == dec"-1" + setprecision(Decimal, 9) + # comx640 + @test cmp(dec"0", dec"0") == dec"0" + # comx641 + @test cmp(dec"0", dec"-0") == dec"0" + # comx642 + @test cmp(dec"0", dec"-0.0") == dec"0" + # comx643 + @test cmp(dec"0", dec"0.0") == dec"0" + # comx644 + @test cmp(dec"-0", dec"0") == dec"0" + # comx645 + @test cmp(dec"-0", dec"-0") == dec"0" + # comx646 + @test cmp(dec"-0", dec"-0.0") == dec"0" + # comx647 + @test cmp(dec"-0", dec"0.0") == dec"0" + # comx648 + @test cmp(dec"0.0", dec"0") == dec"0" + # comx649 + @test cmp(dec"0.0", dec"-0") == dec"0" + # comx650 + @test cmp(dec"0.0", dec"-0.0") == dec"0" + # comx651 + @test cmp(dec"0.0", dec"0.0") == dec"0" + # comx652 + @test cmp(dec"-0.0", dec"0") == dec"0" + # comx653 + @test cmp(dec"-0.0", dec"-0") == dec"0" + # comx654 + @test cmp(dec"-0.0", dec"-0.0") == dec"0" + # comx655 + @test cmp(dec"-0.0", dec"0.0") == dec"0" + # comx656 + @test cmp(dec"-0e1", dec"0.0") == dec"0" + # comx657 + @test cmp(dec"-0e2", dec"0.0") == dec"0" + # comx658 + @test cmp(dec"0e1", dec"0.0") == dec"0" + # comx659 + @test cmp(dec"0e2", dec"0.0") == dec"0" + # comx660 + @test cmp(dec"-0e1", dec"0") == dec"0" + # comx661 + @test cmp(dec"-0e2", dec"0") == dec"0" + # comx662 + @test cmp(dec"0e1", dec"0") == dec"0" + # comx663 + @test cmp(dec"0e2", dec"0") == dec"0" + # comx664 + @test cmp(dec"-0e1", dec"-0e1") == dec"0" + # comx665 + @test cmp(dec"-0e2", dec"-0e1") == dec"0" + # comx666 + @test cmp(dec"0e1", dec"-0e1") == dec"0" + # comx667 + @test cmp(dec"0e2", dec"-0e1") == dec"0" + # comx668 + @test cmp(dec"-0e1", dec"-0e2") == dec"0" + # comx669 + @test cmp(dec"-0e2", dec"-0e2") == dec"0" + # comx670 + @test cmp(dec"0e1", dec"-0e2") == dec"0" + # comx671 + @test cmp(dec"0e2", dec"-0e2") == dec"0" + # comx672 + @test cmp(dec"-0e1", dec"0e1") == dec"0" + # comx673 + @test cmp(dec"-0e2", dec"0e1") == dec"0" + # comx674 + @test cmp(dec"0e1", dec"0e1") == dec"0" + # comx675 + @test cmp(dec"0e2", dec"0e1") == dec"0" + # comx676 + @test cmp(dec"-0e1", dec"0e2") == dec"0" + # comx677 + @test cmp(dec"-0e2", dec"0e2") == dec"0" + # comx678 + @test cmp(dec"0e1", dec"0e2") == dec"0" + # comx679 + @test cmp(dec"0e2", dec"0e2") == dec"0" + setprecision(Decimal, 20) + # comx680 + @test cmp(dec"12", dec"12") == dec"0" + # comx681 + @test cmp(dec"12", dec"12.0") == dec"0" + # comx682 + @test cmp(dec"12", dec"12.00") == dec"0" + # comx683 + @test cmp(dec"12", dec"12.000") == dec"0" + # comx684 + @test cmp(dec"12", dec"12.0000") == dec"0" + # comx685 + @test cmp(dec"12", dec"12.00000") == dec"0" + # comx686 + @test cmp(dec"12", dec"12.000000") == dec"0" + # comx687 + @test cmp(dec"12", dec"12.0000000") == dec"0" + # comx688 + @test cmp(dec"12", dec"12.00000000") == dec"0" + # comx689 + @test cmp(dec"12", dec"12.000000000") == dec"0" + # comx690 + @test cmp(dec"12", dec"12") == dec"0" + # comx691 + @test cmp(dec"12.0", dec"12") == dec"0" + # comx692 + @test cmp(dec"12.00", dec"12") == dec"0" + # comx693 + @test cmp(dec"12.000", dec"12") == dec"0" + # comx694 + @test cmp(dec"12.0000", dec"12") == dec"0" + # comx695 + @test cmp(dec"12.00000", dec"12") == dec"0" + # comx696 + @test cmp(dec"12.000000", dec"12") == dec"0" + # comx697 + @test cmp(dec"12.0000000", dec"12") == dec"0" + # comx698 + @test cmp(dec"12.00000000", dec"12") == dec"0" + # comx699 + @test cmp(dec"12.000000000", dec"12") == dec"0" + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + setprecision(Decimal, 9) + # comx701 + @test cmp(dec"12345678000", dec"1") == dec"1" + # comx702 + @test cmp(dec"1", dec"12345678000") == dec"-1" + # comx703 + @test cmp(dec"1234567800", dec"1") == dec"1" + # comx704 + @test cmp(dec"1", dec"1234567800") == dec"-1" + # comx705 + @test cmp(dec"1234567890", dec"1") == dec"1" + # comx706 + @test cmp(dec"1", dec"1234567890") == dec"-1" + # comx707 + @test cmp(dec"1234567891", dec"1") == dec"1" + # comx708 + @test cmp(dec"1", dec"1234567891") == dec"-1" + # comx709 + @test cmp(dec"12345678901", dec"1") == dec"1" + # comx710 + @test cmp(dec"1", dec"12345678901") == dec"-1" + # comx711 + @test cmp(dec"1234567896", dec"1") == dec"1" + # comx712 + @test cmp(dec"1", dec"1234567896") == dec"-1" + # comx713 + @test cmp(dec"-1234567891", dec"1") == dec"-1" + # comx714 + @test cmp(dec"1", dec"-1234567891") == dec"1" + # comx715 + @test cmp(dec"-12345678901", dec"1") == dec"-1" + # comx716 + @test cmp(dec"1", dec"-12345678901") == dec"1" + # comx717 + @test cmp(dec"-1234567896", dec"1") == dec"-1" + # comx718 + @test cmp(dec"1", dec"-1234567896") == dec"1" + setprecision(Decimal, 15) + # comx721 + @test cmp(dec"12345678000", dec"1") == dec"1" + # comx722 + @test cmp(dec"1", dec"12345678000") == dec"-1" + # comx723 + @test cmp(dec"1234567800", dec"1") == dec"1" + # comx724 + @test cmp(dec"1", dec"1234567800") == dec"-1" + # comx725 + @test cmp(dec"1234567890", dec"1") == dec"1" + # comx726 + @test cmp(dec"1", dec"1234567890") == dec"-1" + # comx727 + @test cmp(dec"1234567891", dec"1") == dec"1" + # comx728 + @test cmp(dec"1", dec"1234567891") == dec"-1" + # comx729 + @test cmp(dec"12345678901", dec"1") == dec"1" + # comx730 + @test cmp(dec"1", dec"12345678901") == dec"-1" + # comx731 + @test cmp(dec"1234567896", dec"1") == dec"1" + # comx732 + @test cmp(dec"1", dec"1234567896") == dec"-1" + setprecision(Decimal, 5) + # comx740 + @test cmp(dec"1", dec"0.9999999") == dec"1" + # comx741 + @test cmp(dec"1", dec"0.999999") == dec"1" + # comx742 + @test cmp(dec"1", dec"0.99999") == dec"1" + # comx743 + @test cmp(dec"1", dec"1.0000") == dec"0" + # comx744 + @test cmp(dec"1", dec"1.00001") == dec"-1" + # comx745 + @test cmp(dec"1", dec"1.000001") == dec"-1" + # comx746 + @test cmp(dec"1", dec"1.0000001") == dec"-1" + # comx750 + @test cmp(dec"0.9999999", dec"1") == dec"-1" + # comx751 + @test cmp(dec"0.999999", dec"1") == dec"-1" + # comx752 + @test cmp(dec"0.99999", dec"1") == dec"-1" + # comx753 + @test cmp(dec"1.0000", dec"1") == dec"0" + # comx754 + @test cmp(dec"1.00001", dec"1") == dec"1" + # comx755 + @test cmp(dec"1.000001", dec"1") == dec"1" + # comx756 + @test cmp(dec"1.0000001", dec"1") == dec"1" + # comx760 + @test cmp(dec"-36852134.84194296250843579428931", dec"-5830629.8347085025808756560357940") == dec"-1" + # comx761 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.84194296250843579428931") == dec"0" + # comx762 + @test cmp(dec"-36852134.94194296250843579428931", dec"-36852134.84194296250843579428931") == dec"-1" + # comx763 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 11) + # comx764 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 10) + # comx765 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 9) + # comx766 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 8) + # comx767 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 7) + # comx768 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 6) + # comx769 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 5) + # comx770 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 4) + # comx771 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 3) + # comx772 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 2) + # comx773 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 1) + # comx774 + @test cmp(dec"-36852134.84194296250843579428931", dec"-36852134.94194296250843579428931") == dec"1" + setprecision(Decimal, 9) + Decimals.CONTEXT.Emax = 999999999 + Decimals.CONTEXT.Emin = -999999999 + # comx880 + @test cmp(dec"+1.23456789012345e-0", dec"9e+999999999") == dec"-1" + # comx881 + @test cmp(dec"9e+999999999", dec"+1.23456789012345e-0") == dec"1" + # comx882 + @test cmp(dec"+0.100", dec"9e-999999999") == dec"1" + # comx883 + @test cmp(dec"9e-999999999", dec"+0.100") == dec"-1" + # comx885 + @test cmp(dec"-1.23456789012345e-0", dec"9e+999999999") == dec"-1" + # comx886 + @test cmp(dec"9e+999999999", dec"-1.23456789012345e-0") == dec"1" + # comx887 + @test cmp(dec"-0.100", dec"9e-999999999") == dec"-1" + # comx888 + @test cmp(dec"9e-999999999", dec"-0.100") == dec"1" + # comx889 + @test cmp(dec"1e-599999999", dec"1e-400000001") == dec"-1" + # comx890 + @test cmp(dec"1e-599999999", dec"1e-400000000") == dec"-1" + # comx891 + @test cmp(dec"1e-600000000", dec"1e-400000000") == dec"-1" + # comx892 + @test cmp(dec"9e-999999998", dec"0.01") == dec"-1" + # comx893 + @test cmp(dec"9e-999999998", dec"0.1") == dec"-1" + # comx894 + @test cmp(dec"0.01", dec"9e-999999998") == dec"1" + # comx895 + @test cmp(dec"1e599999999", dec"1e400000001") == dec"1" + # comx896 + @test cmp(dec"1e599999999", dec"1e400000000") == dec"1" + # comx897 + @test cmp(dec"1e600000000", dec"1e400000000") == dec"1" + # comx898 + @test cmp(dec"9e999999998", dec"100") == dec"1" + # comx899 + @test cmp(dec"9e999999998", dec"10") == dec"1" + # comx900 + @test cmp(dec"100", dec"9e999999998") == dec"-1" + # comx901 + @test cmp(dec"1e+777777777", dec"1e+411111111") == dec"1" + # comx902 + @test cmp(dec"1e+777777777", dec"-1e+411111111") == dec"1" + # comx903 + @test cmp(dec"-1e+777777777", dec"1e+411111111") == dec"-1" + # comx904 + @test cmp(dec"-1e+777777777", dec"-1e+411111111") == dec"-1" + # comx905 + @test cmp(dec"1e-777777777", dec"1e-411111111") == dec"-1" + # comx906 + @test cmp(dec"1e-777777777", dec"-1e-411111111") == dec"1" + # comx907 + @test cmp(dec"-1e-777777777", dec"1e-411111111") == dec"-1" + # comx908 + @test cmp(dec"-1e-777777777", dec"-1e-411111111") == dec"1" + # comx910 + @test cmp(dec"0e-383", dec"0") == dec"0" + # comx911 + @test cmp(dec"0e-383", dec"-0") == dec"0" + # comx912 + @test cmp(dec"-0e-383", dec"0") == dec"0" + # comx913 + @test cmp(dec"-0e-383", dec"-0") == dec"0" + # comx914 + @test cmp(dec"0e-383", dec"0e+384") == dec"0" + # comx915 + @test cmp(dec"0e-383", dec"-0e+384") == dec"0" + # comx916 + @test cmp(dec"-0e-383", dec"0e+384") == dec"0" + # comx917 + @test cmp(dec"-0e-383", dec"-0e+384") == dec"0" + # comx918 + @test cmp(dec"0", dec"0e+384") == dec"0" + # comx919 + @test cmp(dec"0", dec"-0e+384") == dec"0" + # comx920 + @test cmp(dec"-0", dec"0e+384") == dec"0" + # comx921 + @test cmp(dec"-0", dec"-0e+384") == dec"0" + # comx930 + @test cmp(dec"0e+384", dec"0") == dec"0" + # comx931 + @test cmp(dec"0e+384", dec"-0") == dec"0" + # comx932 + @test cmp(dec"-0e+384", dec"0") == dec"0" + # comx933 + @test cmp(dec"-0e+384", dec"-0") == dec"0" + # comx934 + @test cmp(dec"0e+384", dec"0e-383") == dec"0" + # comx935 + @test cmp(dec"0e+384", dec"-0e-383") == dec"0" + # comx936 + @test cmp(dec"-0e+384", dec"0e-383") == dec"0" + # comx937 + @test cmp(dec"-0e+384", dec"-0e-383") == dec"0" + # comx938 + @test cmp(dec"0", dec"0e-383") == dec"0" + # comx939 + @test cmp(dec"0", dec"-0e-383") == dec"0" + # comx940 + @test cmp(dec"-0", dec"0e-383") == dec"0" + # comx941 + @test cmp(dec"-0", dec"-0e-383") == dec"0" +end diff --git a/test/dectests/test_minus.jl b/test/dectests/test_minus.jl new file mode 100644 index 0000000..fa5a181 --- /dev/null +++ b/test/dectests/test_minus.jl @@ -0,0 +1,227 @@ +using Decimals +using Test + +@testset "Minus" begin + setprecision(Decimal, 9) + setrounding(Decimal, RoundNearestTiesAway) + Decimals.CONTEXT.Emax = 384 + Decimals.CONTEXT.Emin = -383 + # minx001 + @test -(dec"1") == dec"-1" + # minx002 + @test -(dec"-1") == dec"1" + # minx003 + @test -(dec"1.00") == dec"-1.00" + # minx004 + @test -(dec"-1.00") == dec"1.00" + # minx005 + @test -(dec"0") == dec"0" + # minx006 + @test -(dec"0.00") == dec"0.00" + # minx007 + @test -(dec"00.0") == dec"0.0" + # minx008 + @test -(dec"00.00") == dec"0.00" + # minx009 + @test -(dec"00") == dec"0" + # minx010 + @test -(dec"-2") == dec"2" + # minx011 + @test -(dec"2") == dec"-2" + # minx012 + @test -(dec"-2.00") == dec"2.00" + # minx013 + @test -(dec"2.00") == dec"-2.00" + # minx014 + @test -(dec"-0") == dec"0" + # minx015 + @test -(dec"-0.00") == dec"0.00" + # minx016 + @test -(dec"-00.0") == dec"0.0" + # minx017 + @test -(dec"-00.00") == dec"0.00" + # minx018 + @test -(dec"-00") == dec"0" + # minx020 + @test -(dec"-0e3") == dec"0e+3" + # minx021 + @test -(dec"-0e2") == dec"0e+2" + # minx022 + @test -(dec"-0e1") == dec"0e+1" + # minx023 + @test -(dec"-0e0") == dec"0" + # minx024 + @test -(dec"+0e0") == dec"0" + # minx025 + @test -(dec"+0e1") == dec"0e+1" + # minx026 + @test -(dec"+0e2") == dec"0e+2" + # minx027 + @test -(dec"+0e3") == dec"0e+3" + # minx030 + @test -(dec"-5e3") == dec"5e+3" + # minx031 + @test -(dec"-5e8") == dec"5e+8" + # minx032 + @test -(dec"-5e13") == dec"5e+13" + # minx033 + @test -(dec"-5e18") == dec"5e+18" + # minx034 + @test -(dec"+5e3") == dec"-5e+3" + # minx035 + @test -(dec"+5e8") == dec"-5e+8" + # minx036 + @test -(dec"+5e13") == dec"-5e+13" + # minx037 + @test -(dec"+5e18") == dec"-5e+18" + # minx050 + @test -(dec"-2000000") == dec"2000000" + # minx051 + @test -(dec"2000000") == dec"-2000000" + setprecision(Decimal, 7) + # minx052 + @test -(dec"-2000000") == dec"2000000" + # minx053 + @test -(dec"2000000") == dec"-2000000" + setprecision(Decimal, 6) + # minx054 + @test -(dec"-2000000") == dec"2.00000e+6" + # minx055 + @test -(dec"2000000") == dec"-2.00000e+6" + setprecision(Decimal, 3) + # minx056 + @test -(dec"-2000000") == dec"2.00e+6" + # minx057 + @test -(dec"2000000") == dec"-2.00e+6" + setprecision(Decimal, 9) + # minx060 + @test -(dec"56267e-10") == dec"-0.0000056267" + # minx061 + @test -(dec"56267e-5") == dec"-0.56267" + # minx062 + @test -(dec"56267e-2") == dec"-562.67" + # minx063 + @test -(dec"56267e-1") == dec"-5626.7" + # minx065 + @test -(dec"56267e-0") == dec"-56267" + # minx066 + @test -(dec"56267e+0") == dec"-56267" + # minx067 + @test -(dec"56267e+1") == dec"-5.6267e+5" + # minx068 + @test -(dec"56267e+2") == dec"-5.6267e+6" + # minx069 + @test -(dec"56267e+3") == dec"-5.6267e+7" + # minx070 + @test -(dec"56267e+4") == dec"-5.6267e+8" + # minx071 + @test -(dec"56267e+5") == dec"-5.6267e+9" + # minx072 + @test -(dec"56267e+6") == dec"-5.6267e+10" + # minx080 + @test -(dec"-56267e-10") == dec"0.0000056267" + # minx081 + @test -(dec"-56267e-5") == dec"0.56267" + # minx082 + @test -(dec"-56267e-2") == dec"562.67" + # minx083 + @test -(dec"-56267e-1") == dec"5626.7" + # minx085 + @test -(dec"-56267e-0") == dec"56267" + # minx086 + @test -(dec"-56267e+0") == dec"56267" + # minx087 + @test -(dec"-56267e+1") == dec"5.6267e+5" + # minx088 + @test -(dec"-56267e+2") == dec"5.6267e+6" + # minx089 + @test -(dec"-56267e+3") == dec"5.6267e+7" + # minx090 + @test -(dec"-56267e+4") == dec"5.6267e+8" + # minx091 + @test -(dec"-56267e+5") == dec"5.6267e+9" + # minx092 + @test -(dec"-56267e+6") == dec"5.6267e+10" + Decimals.CONTEXT.Emax = 999999999 + Decimals.CONTEXT.Emin = -999999999 + setprecision(Decimal, 3) + # minx100 + @test_throws OverflowError -(dec"9.999e+999999999") + # minx101 + @test_throws OverflowError -(dec"-9.999e+999999999") + setprecision(Decimal, 3) + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + # minx110 + @test -(dec"1.00e-999") == dec"-1.00e-999" + # minx111 + @test -(dec"0.1e-999") == dec"-1e-1000" + # minx112 + @test -(dec"0.10e-999") == dec"-1.0e-1000" + # minx113 + @test -(dec"0.100e-999") == dec"-1.0e-1000" + # minx114 + @test -(dec"0.01e-999") == dec"-1e-1001" + # minx115 + @test -(dec"0.999e-999") == dec"-1.00e-999" + # minx116 + @test -(dec"0.099e-999") == dec"-1.0e-1000" + # minx117 + @test -(dec"0.009e-999") == dec"-1e-1001" + # minx118 + @test -(dec"0.001e-999") == dec"-0e-1001" + # minx119 + @test -(dec"0.0009e-999") == dec"-0e-1001" + # minx120 + @test -(dec"0.0001e-999") == dec"-0e-1001" + # minx130 + @test -(dec"-1.00e-999") == dec"1.00e-999" + # minx131 + @test -(dec"-0.1e-999") == dec"1e-1000" + # minx132 + @test -(dec"-0.10e-999") == dec"1.0e-1000" + # minx133 + @test -(dec"-0.100e-999") == dec"1.0e-1000" + # minx134 + @test -(dec"-0.01e-999") == dec"1e-1001" + # minx135 + @test -(dec"-0.999e-999") == dec"1.00e-999" + # minx136 + @test -(dec"-0.099e-999") == dec"1.0e-1000" + # minx137 + @test -(dec"-0.009e-999") == dec"1e-1001" + # minx138 + @test -(dec"-0.001e-999") == dec"0e-1001" + # minx139 + @test -(dec"-0.0009e-999") == dec"0e-1001" + # minx140 + @test -(dec"-0.0001e-999") == dec"0e-1001" + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + setprecision(Decimal, 9) + # minx301 + @test -(dec"12345678000") == dec"-1.23456780e+10" + # minx302 + @test -(dec"1234567800") == dec"-1.23456780e+9" + # minx303 + @test -(dec"1234567890") == dec"-1.23456789e+9" + # minx304 + @test -(dec"1234567891") == dec"-1.23456789e+9" + # minx305 + @test -(dec"12345678901") == dec"-1.23456789e+10" + # minx306 + @test -(dec"1234567896") == dec"-1.23456790e+9" + setprecision(Decimal, 15) + # minx321 + @test -(dec"12345678000") == dec"-12345678000" + # minx322 + @test -(dec"1234567800") == dec"-1234567800" + # minx323 + @test -(dec"1234567890") == dec"-1234567890" + # minx324 + @test -(dec"1234567891") == dec"-1234567891" + # minx325 + @test -(dec"12345678901") == dec"-12345678901" + # minx326 + @test -(dec"1234567896") == dec"-1234567896" +end diff --git a/test/dectests/test_plus.jl b/test/dectests/test_plus.jl new file mode 100644 index 0000000..a416f2f --- /dev/null +++ b/test/dectests/test_plus.jl @@ -0,0 +1,249 @@ +using Decimals +using Test + +@testset "Plus" begin + setprecision(Decimal, 9) + setrounding(Decimal, RoundNearestTiesAway) + Decimals.CONTEXT.Emax = 384 + Decimals.CONTEXT.Emin = -383 + # plux001 + @test +(dec"1") == dec"1" + # plux002 + @test +(dec"-1") == dec"-1" + # plux003 + @test +(dec"1.00") == dec"1.00" + # plux004 + @test +(dec"-1.00") == dec"-1.00" + # plux005 + @test +(dec"0") == dec"0" + # plux006 + @test +(dec"0.00") == dec"0.00" + # plux007 + @test +(dec"00.0") == dec"0.0" + # plux008 + @test +(dec"00.00") == dec"0.00" + # plux009 + @test +(dec"00") == dec"0" + # plux010 + @test +(dec"-2") == dec"-2" + # plux011 + @test +(dec"2") == dec"2" + # plux012 + @test +(dec"-2.00") == dec"-2.00" + # plux013 + @test +(dec"2.00") == dec"2.00" + # plux014 + @test +(dec"-0") == dec"0" + # plux015 + @test +(dec"-0.00") == dec"0.00" + # plux016 + @test +(dec"-00.0") == dec"0.0" + # plux017 + @test +(dec"-00.00") == dec"0.00" + # plux018 + @test +(dec"-00") == dec"0" + # plux020 + @test +(dec"-2000000") == dec"-2000000" + # plux021 + @test +(dec"2000000") == dec"2000000" + setprecision(Decimal, 7) + # plux022 + @test +(dec"-2000000") == dec"-2000000" + # plux023 + @test +(dec"2000000") == dec"2000000" + setprecision(Decimal, 6) + # plux024 + @test +(dec"-2000000") == dec"-2.00000e+6" + # plux025 + @test +(dec"2000000") == dec"2.00000e+6" + setprecision(Decimal, 3) + # plux026 + @test +(dec"-2000000") == dec"-2.00e+6" + # plux027 + @test +(dec"2000000") == dec"2.00e+6" + setprecision(Decimal, 9) + # plux060 + @test +(dec"56267e-10") == dec"0.0000056267" + # plux061 + @test +(dec"56267e-5") == dec"0.56267" + # plux062 + @test +(dec"56267e-2") == dec"562.67" + # plux063 + @test +(dec"56267e-1") == dec"5626.7" + # plux065 + @test +(dec"56267e-0") == dec"56267" + # plux066 + @test +(dec"56267e+0") == dec"56267" + # plux067 + @test +(dec"56267e+1") == dec"5.6267e+5" + # plux068 + @test +(dec"56267e+2") == dec"5.6267e+6" + # plux069 + @test +(dec"56267e+3") == dec"5.6267e+7" + # plux070 + @test +(dec"56267e+4") == dec"5.6267e+8" + # plux071 + @test +(dec"56267e+5") == dec"5.6267e+9" + # plux072 + @test +(dec"56267e+6") == dec"5.6267e+10" + # plux080 + @test +(dec"-56267e-10") == dec"-0.0000056267" + # plux081 + @test +(dec"-56267e-5") == dec"-0.56267" + # plux082 + @test +(dec"-56267e-2") == dec"-562.67" + # plux083 + @test +(dec"-56267e-1") == dec"-5626.7" + # plux085 + @test +(dec"-56267e-0") == dec"-56267" + # plux086 + @test +(dec"-56267e+0") == dec"-56267" + # plux087 + @test +(dec"-56267e+1") == dec"-5.6267e+5" + # plux088 + @test +(dec"-56267e+2") == dec"-5.6267e+6" + # plux089 + @test +(dec"-56267e+3") == dec"-5.6267e+7" + # plux090 + @test +(dec"-56267e+4") == dec"-5.6267e+8" + # plux091 + @test +(dec"-56267e+5") == dec"-5.6267e+9" + # plux092 + @test +(dec"-56267e+6") == dec"-5.6267e+10" + # plux120 + @test +(dec"-0e3") == dec"0e+3" + # plux121 + @test +(dec"-0e2") == dec"0e+2" + # plux122 + @test +(dec"-0e1") == dec"0e+1" + # plux123 + @test +(dec"-0e0") == dec"0" + # plux124 + @test +(dec"+0e0") == dec"0" + # plux125 + @test +(dec"+0e1") == dec"0e+1" + # plux126 + @test +(dec"+0e2") == dec"0e+2" + # plux127 + @test +(dec"+0e3") == dec"0e+3" + # plux130 + @test +(dec"-5e3") == dec"-5e+3" + # plux131 + @test +(dec"-5e8") == dec"-5e+8" + # plux132 + @test +(dec"-5e13") == dec"-5e+13" + # plux133 + @test +(dec"-5e18") == dec"-5e+18" + # plux134 + @test +(dec"+5e3") == dec"5e+3" + # plux135 + @test +(dec"+5e8") == dec"5e+8" + # plux136 + @test +(dec"+5e13") == dec"5e+13" + # plux137 + @test +(dec"+5e18") == dec"5e+18" + Decimals.CONTEXT.Emax = 999999999 + Decimals.CONTEXT.Emin = -999999999 + setprecision(Decimal, 3) + # plux160 + @test_throws OverflowError +(dec"9.999e+999999999") + # plux161 + @test_throws OverflowError +(dec"-9.999e+999999999") + setprecision(Decimal, 3) + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + # plux210 + @test +(dec"1.00e-999") == dec"1.00e-999" + # plux211 + @test +(dec"0.1e-999") == dec"1e-1000" + # plux212 + @test +(dec"0.10e-999") == dec"1.0e-1000" + # plux213 + @test +(dec"0.100e-999") == dec"1.0e-1000" + # plux214 + @test +(dec"0.01e-999") == dec"1e-1001" + # plux215 + @test +(dec"0.999e-999") == dec"1.00e-999" + # plux216 + @test +(dec"0.099e-999") == dec"1.0e-1000" + # plux217 + @test +(dec"0.009e-999") == dec"1e-1001" + # plux218 + @test +(dec"0.001e-999") == dec"0e-1001" + # plux219 + @test +(dec"0.0009e-999") == dec"0e-1001" + # plux220 + @test +(dec"0.0001e-999") == dec"0e-1001" + # plux230 + @test +(dec"-1.00e-999") == dec"-1.00e-999" + # plux231 + @test +(dec"-0.1e-999") == dec"-1e-1000" + # plux232 + @test +(dec"-0.10e-999") == dec"-1.0e-1000" + # plux233 + @test +(dec"-0.100e-999") == dec"-1.0e-1000" + # plux234 + @test +(dec"-0.01e-999") == dec"-1e-1001" + # plux235 + @test +(dec"-0.999e-999") == dec"-1.00e-999" + # plux236 + @test +(dec"-0.099e-999") == dec"-1.0e-1000" + # plux237 + @test +(dec"-0.009e-999") == dec"-1e-1001" + # plux238 + @test +(dec"-0.001e-999") == dec"-0e-1001" + # plux239 + @test +(dec"-0.0009e-999") == dec"-0e-1001" + # plux240 + @test +(dec"-0.0001e-999") == dec"-0e-1001" + setprecision(Decimal, 16) + Decimals.CONTEXT.Emax = 384 + Decimals.CONTEXT.Emin = -383 + # plux251 + @test +(dec"7e-398") == dec"7e-398" + # plux252 + @test +(dec"0e-398") == dec"0e-398" + # plux253 + @test +(dec"7e-399") == dec"1e-398" + # plux254 + @test +(dec"4e-399") == dec"0e-398" + # plux255 + @test +(dec"7e-400") == dec"0e-398" + # plux256 + @test +(dec"7e-401") == dec"0e-398" + # plux257 + @test +(dec"0e-399") == dec"0e-398" + # plux258 + @test +(dec"0e-400") == dec"0e-398" + # plux259 + @test +(dec"0e-401") == dec"0e-398" + Decimals.CONTEXT.Emax = 999 + Decimals.CONTEXT.Emin = -999 + setprecision(Decimal, 9) + # plux301 + @test +(dec"12345678000") == dec"1.23456780e+10" + # plux302 + @test +(dec"1234567800") == dec"1.23456780e+9" + # plux303 + @test +(dec"1234567890") == dec"1.23456789e+9" + # plux304 + @test +(dec"1234567891") == dec"1.23456789e+9" + # plux305 + @test +(dec"12345678901") == dec"1.23456789e+10" + # plux306 + @test +(dec"1234567896") == dec"1.23456790e+9" + setprecision(Decimal, 15) + # plux321 + @test +(dec"12345678000") == dec"12345678000" + # plux322 + @test +(dec"1234567800") == dec"1234567800" + # plux323 + @test +(dec"1234567890") == dec"1234567890" + # plux324 + @test +(dec"1234567891") == dec"1234567891" + # plux325 + @test +(dec"12345678901") == dec"12345678901" + # plux326 + @test +(dec"1234567896") == dec"1234567896" + setprecision(Decimal, 9) +end diff --git a/test/runtests.jl b/test/runtests.jl index cf0e978..5bf5c95 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,14 +15,17 @@ global d = [ include("test_arithmetic.jl") include("test_bigint.jl") include("test_constructor.jl") -include("test_parse.jl") -include("test_show.jl") +include("test_context.jl") include("test_decimal.jl") include("test_equals.jl") include("test_hash.jl") include("test_norm.jl") +include("test_parse.jl") include("test_round.jl") +include("test_show.jl") -include("test_compare.jl") +include("dectests/test_compare.jl") +include("dectests/test_minus.jl") +include("dectests/test_plus.jl") end diff --git a/test/test_compare.jl b/test/test_compare.jl deleted file mode 100644 index ace7c50..0000000 --- a/test/test_compare.jl +++ /dev/null @@ -1,827 +0,0 @@ -using Decimals -using Test - -@testset "Compare" begin - # com001 - @test cmp(dec"-2", dec"-2") == 0 - # com002 - @test cmp(dec"-2", dec"-1") == -1 - # com003 - @test cmp(dec"-2", dec"0") == -1 - # com004 - @test cmp(dec"-2", dec"1") == -1 - # com005 - @test cmp(dec"-2", dec"2") == -1 - # com006 - @test cmp(dec"-1", dec"-2") == 1 - # com007 - @test cmp(dec"-1", dec"-1") == 0 - # com008 - @test cmp(dec"-1", dec"0") == -1 - # com009 - @test cmp(dec"-1", dec"1") == -1 - # com010 - @test cmp(dec"-1", dec"2") == -1 - # com011 - @test cmp(dec"0", dec"-2") == 1 - # com012 - @test cmp(dec"0", dec"-1") == 1 - # com013 - @test cmp(dec"0", dec"0") == 0 - # com014 - @test cmp(dec"0", dec"1") == -1 - # com015 - @test cmp(dec"0", dec"2") == -1 - # com016 - @test cmp(dec"1", dec"-2") == 1 - # com017 - @test cmp(dec"1", dec"-1") == 1 - # com018 - @test cmp(dec"1", dec"0") == 1 - # com019 - @test cmp(dec"1", dec"1") == 0 - # com020 - @test cmp(dec"1", dec"2") == -1 - # com021 - @test cmp(dec"2", dec"-2") == 1 - # com022 - @test cmp(dec"2", dec"-1") == 1 - # com023 - @test cmp(dec"2", dec"0") == 1 - # com025 - @test cmp(dec"2", dec"1") == 1 - # com026 - @test cmp(dec"2", dec"2") == 0 - # com031 - @test cmp(dec"-20", dec"-20") == 0 - # com032 - @test cmp(dec"-20", dec"-10") == -1 - # com033 - @test cmp(dec"-20", dec"00") == -1 - # com034 - @test cmp(dec"-20", dec"10") == -1 - # com035 - @test cmp(dec"-20", dec"20") == -1 - # com036 - @test cmp(dec"-10", dec"-20") == 1 - # com037 - @test cmp(dec"-10", dec"-10") == 0 - # com038 - @test cmp(dec"-10", dec"00") == -1 - # com039 - @test cmp(dec"-10", dec"10") == -1 - # com040 - @test cmp(dec"-10", dec"20") == -1 - # com041 - @test cmp(dec"00", dec"-20") == 1 - # com042 - @test cmp(dec"00", dec"-10") == 1 - # com043 - @test cmp(dec"00", dec"00") == 0 - # com044 - @test cmp(dec"00", dec"10") == -1 - # com045 - @test cmp(dec"00", dec"20") == -1 - # com046 - @test cmp(dec"10", dec"-20") == 1 - # com047 - @test cmp(dec"10", dec"-10") == 1 - # com048 - @test cmp(dec"10", dec"00") == 1 - # com049 - @test cmp(dec"10", dec"10") == 0 - # com050 - @test cmp(dec"10", dec"20") == -1 - # com051 - @test cmp(dec"20", dec"-20") == 1 - # com052 - @test cmp(dec"20", dec"-10") == 1 - # com053 - @test cmp(dec"20", dec"00") == 1 - # com055 - @test cmp(dec"20", dec"10") == 1 - # com056 - @test cmp(dec"20", dec"20") == 0 - # com061 - @test cmp(dec"-2.0", dec"-2.0") == 0 - # com062 - @test cmp(dec"-2.0", dec"-1.0") == -1 - # com063 - @test cmp(dec"-2.0", dec"0.0") == -1 - # com064 - @test cmp(dec"-2.0", dec"1.0") == -1 - # com065 - @test cmp(dec"-2.0", dec"2.0") == -1 - # com066 - @test cmp(dec"-1.0", dec"-2.0") == 1 - # com067 - @test cmp(dec"-1.0", dec"-1.0") == 0 - # com068 - @test cmp(dec"-1.0", dec"0.0") == -1 - # com069 - @test cmp(dec"-1.0", dec"1.0") == -1 - # com070 - @test cmp(dec"-1.0", dec"2.0") == -1 - # com071 - @test cmp(dec"0.0", dec"-2.0") == 1 - # com072 - @test cmp(dec"0.0", dec"-1.0") == 1 - # com073 - @test cmp(dec"0.0", dec"0.0") == 0 - # com074 - @test cmp(dec"0.0", dec"1.0") == -1 - # com075 - @test cmp(dec"0.0", dec"2.0") == -1 - # com076 - @test cmp(dec"1.0", dec"-2.0") == 1 - # com077 - @test cmp(dec"1.0", dec"-1.0") == 1 - # com078 - @test cmp(dec"1.0", dec"0.0") == 1 - # com079 - @test cmp(dec"1.0", dec"1.0") == 0 - # com080 - @test cmp(dec"1.0", dec"2.0") == -1 - # com081 - @test cmp(dec"2.0", dec"-2.0") == 1 - # com082 - @test cmp(dec"2.0", dec"-1.0") == 1 - # com083 - @test cmp(dec"2.0", dec"0.0") == 1 - # com085 - @test cmp(dec"2.0", dec"1.0") == 1 - # com086 - @test cmp(dec"2.0", dec"2.0") == 0 - # com100 - @test cmp(dec"7.0", dec"7.0") == 0 - # com101 - @test cmp(dec"7.0", dec"7") == 0 - # com102 - @test cmp(dec"7", dec"7.0") == 0 - # com103 - @test cmp(dec"7E+0", dec"7.0") == 0 - # com104 - @test cmp(dec"70E-1", dec"7.0") == 0 - # com105 - @test cmp(dec"0.7E+1", dec"7") == 0 - # com106 - @test cmp(dec"70E-1", dec"7") == 0 - # com107 - @test cmp(dec"7.0", dec"7E+0") == 0 - # com108 - @test cmp(dec"7.0", dec"70E-1") == 0 - # com109 - @test cmp(dec"7", dec"0.7E+1") == 0 - # com110 - @test cmp(dec"7", dec"70E-1") == 0 - # com120 - @test cmp(dec"8.0", dec"7.0") == 1 - # com121 - @test cmp(dec"8.0", dec"7") == 1 - # com122 - @test cmp(dec"8", dec"7.0") == 1 - # com123 - @test cmp(dec"8E+0", dec"7.0") == 1 - # com124 - @test cmp(dec"80E-1", dec"7.0") == 1 - # com125 - @test cmp(dec"0.8E+1", dec"7") == 1 - # com126 - @test cmp(dec"80E-1", dec"7") == 1 - # com127 - @test cmp(dec"8.0", dec"7E+0") == 1 - # com128 - @test cmp(dec"8.0", dec"70E-1") == 1 - # com129 - @test cmp(dec"8", dec"0.7E+1") == 1 - # com130 - @test cmp(dec"8", dec"70E-1") == 1 - # com140 - @test cmp(dec"8.0", dec"9.0") == -1 - # com141 - @test cmp(dec"8.0", dec"9") == -1 - # com142 - @test cmp(dec"8", dec"9.0") == -1 - # com143 - @test cmp(dec"8E+0", dec"9.0") == -1 - # com144 - @test cmp(dec"80E-1", dec"9.0") == -1 - # com145 - @test cmp(dec"0.8E+1", dec"9") == -1 - # com146 - @test cmp(dec"80E-1", dec"9") == -1 - # com147 - @test cmp(dec"8.0", dec"9E+0") == -1 - # com148 - @test cmp(dec"8.0", dec"90E-1") == -1 - # com149 - @test cmp(dec"8", dec"0.9E+1") == -1 - # com150 - @test cmp(dec"8", dec"90E-1") == -1 - # com200 - @test cmp(dec"-7.0", dec"7.0") == -1 - # com201 - @test cmp(dec"-7.0", dec"7") == -1 - # com202 - @test cmp(dec"-7", dec"7.0") == -1 - # com203 - @test cmp(dec"-7E+0", dec"7.0") == -1 - # com204 - @test cmp(dec"-70E-1", dec"7.0") == -1 - # com205 - @test cmp(dec"-0.7E+1", dec"7") == -1 - # com206 - @test cmp(dec"-70E-1", dec"7") == -1 - # com207 - @test cmp(dec"-7.0", dec"7E+0") == -1 - # com208 - @test cmp(dec"-7.0", dec"70E-1") == -1 - # com209 - @test cmp(dec"-7", dec"0.7E+1") == -1 - # com210 - @test cmp(dec"-7", dec"70E-1") == -1 - # com220 - @test cmp(dec"-8.0", dec"7.0") == -1 - # com221 - @test cmp(dec"-8.0", dec"7") == -1 - # com222 - @test cmp(dec"-8", dec"7.0") == -1 - # com223 - @test cmp(dec"-8E+0", dec"7.0") == -1 - # com224 - @test cmp(dec"-80E-1", dec"7.0") == -1 - # com225 - @test cmp(dec"-0.8E+1", dec"7") == -1 - # com226 - @test cmp(dec"-80E-1", dec"7") == -1 - # com227 - @test cmp(dec"-8.0", dec"7E+0") == -1 - # com228 - @test cmp(dec"-8.0", dec"70E-1") == -1 - # com229 - @test cmp(dec"-8", dec"0.7E+1") == -1 - # com230 - @test cmp(dec"-8", dec"70E-1") == -1 - # com240 - @test cmp(dec"-8.0", dec"9.0") == -1 - # com241 - @test cmp(dec"-8.0", dec"9") == -1 - # com242 - @test cmp(dec"-8", dec"9.0") == -1 - # com243 - @test cmp(dec"-8E+0", dec"9.0") == -1 - # com244 - @test cmp(dec"-80E-1", dec"9.0") == -1 - # com245 - @test cmp(dec"-0.8E+1", dec"9") == -1 - # com246 - @test cmp(dec"-80E-1", dec"9") == -1 - # com247 - @test cmp(dec"-8.0", dec"9E+0") == -1 - # com248 - @test cmp(dec"-8.0", dec"90E-1") == -1 - # com249 - @test cmp(dec"-8", dec"0.9E+1") == -1 - # com250 - @test cmp(dec"-8", dec"90E-1") == -1 - # com300 - @test cmp(dec"7.0", dec"-7.0") == 1 - # com301 - @test cmp(dec"7.0", dec"-7") == 1 - # com302 - @test cmp(dec"7", dec"-7.0") == 1 - # com303 - @test cmp(dec"7E+0", dec"-7.0") == 1 - # com304 - @test cmp(dec"70E-1", dec"-7.0") == 1 - # com305 - @test cmp(dec".7E+1", dec"-7") == 1 - # com306 - @test cmp(dec"70E-1", dec"-7") == 1 - # com307 - @test cmp(dec"7.0", dec"-7E+0") == 1 - # com308 - @test cmp(dec"7.0", dec"-70E-1") == 1 - # com309 - @test cmp(dec"7", dec"-.7E+1") == 1 - # com310 - @test cmp(dec"7", dec"-70E-1") == 1 - # com320 - @test cmp(dec"8.0", dec"-7.0") == 1 - # com321 - @test cmp(dec"8.0", dec"-7") == 1 - # com322 - @test cmp(dec"8", dec"-7.0") == 1 - # com323 - @test cmp(dec"8E+0", dec"-7.0") == 1 - # com324 - @test cmp(dec"80E-1", dec"-7.0") == 1 - # com325 - @test cmp(dec".8E+1", dec"-7") == 1 - # com326 - @test cmp(dec"80E-1", dec"-7") == 1 - # com327 - @test cmp(dec"8.0", dec"-7E+0") == 1 - # com328 - @test cmp(dec"8.0", dec"-70E-1") == 1 - # com329 - @test cmp(dec"8", dec"-.7E+1") == 1 - # com330 - @test cmp(dec"8", dec"-70E-1") == 1 - # com340 - @test cmp(dec"8.0", dec"-9.0") == 1 - # com341 - @test cmp(dec"8.0", dec"-9") == 1 - # com342 - @test cmp(dec"8", dec"-9.0") == 1 - # com343 - @test cmp(dec"8E+0", dec"-9.0") == 1 - # com344 - @test cmp(dec"80E-1", dec"-9.0") == 1 - # com345 - @test cmp(dec".8E+1", dec"-9") == 1 - # com346 - @test cmp(dec"80E-1", dec"-9") == 1 - # com347 - @test cmp(dec"8.0", dec"-9E+0") == 1 - # com348 - @test cmp(dec"8.0", dec"-90E-1") == 1 - # com349 - @test cmp(dec"8", dec"-.9E+1") == 1 - # com350 - @test cmp(dec"8", dec"-90E-1") == 1 - # com400 - @test cmp(dec"-7.0", dec"-7.0") == 0 - # com401 - @test cmp(dec"-7.0", dec"-7") == 0 - # com402 - @test cmp(dec"-7", dec"-7.0") == 0 - # com403 - @test cmp(dec"-7E+0", dec"-7.0") == 0 - # com404 - @test cmp(dec"-70E-1", dec"-7.0") == 0 - # com405 - @test cmp(dec"-.7E+1", dec"-7") == 0 - # com406 - @test cmp(dec"-70E-1", dec"-7") == 0 - # com407 - @test cmp(dec"-7.0", dec"-7E+0") == 0 - # com408 - @test cmp(dec"-7.0", dec"-70E-1") == 0 - # com409 - @test cmp(dec"-7", dec"-.7E+1") == 0 - # com410 - @test cmp(dec"-7", dec"-70E-1") == 0 - # com420 - @test cmp(dec"-8.0", dec"-7.0") == -1 - # com421 - @test cmp(dec"-8.0", dec"-7") == -1 - # com422 - @test cmp(dec"-8", dec"-7.0") == -1 - # com423 - @test cmp(dec"-8E+0", dec"-7.0") == -1 - # com424 - @test cmp(dec"-80E-1", dec"-7.0") == -1 - # com425 - @test cmp(dec"-.8E+1", dec"-7") == -1 - # com426 - @test cmp(dec"-80E-1", dec"-7") == -1 - # com427 - @test cmp(dec"-8.0", dec"-7E+0") == -1 - # com428 - @test cmp(dec"-8.0", dec"-70E-1") == -1 - # com429 - @test cmp(dec"-8", dec"-.7E+1") == -1 - # com430 - @test cmp(dec"-8", dec"-70E-1") == -1 - # com440 - @test cmp(dec"-8.0", dec"-9.0") == 1 - # com441 - @test cmp(dec"-8.0", dec"-9") == 1 - # com442 - @test cmp(dec"-8", dec"-9.0") == 1 - # com443 - @test cmp(dec"-8E+0", dec"-9.0") == 1 - # com444 - @test cmp(dec"-80E-1", dec"-9.0") == 1 - # com445 - @test cmp(dec"-.8E+1", dec"-9") == 1 - # com446 - @test cmp(dec"-80E-1", dec"-9") == 1 - # com447 - @test cmp(dec"-8.0", dec"-9E+0") == 1 - # com448 - @test cmp(dec"-8.0", dec"-90E-1") == 1 - # com449 - @test cmp(dec"-8", dec"-.9E+1") == 1 - # com450 - @test cmp(dec"-8", dec"-90E-1") == 1 - # com460 - @test cmp(dec"9.99999999E+999999999", dec"9.99999999E+999999999") == 0 - # com461 - @test cmp(dec"-9.99999999E+999999999", dec"9.99999999E+999999999") == -1 - # com462 - @test cmp(dec"9.99999999E+999999999", dec"-9.99999999E+999999999") == 1 - # com463 - @test cmp(dec"-9.99999999E+999999999", dec"-9.99999999E+999999999") == 0 - # com470 - @test cmp(dec"123.4560000000000000E789", dec"123.456E789") == 0 - # com471 - @test cmp(dec"123.456000000000000E-89", dec"123.456E-89") == 0 - # com472 - @test cmp(dec"123.45600000000000E789", dec"123.456E789") == 0 - # com473 - @test cmp(dec"123.4560000000000E-89", dec"123.456E-89") == 0 - # com474 - @test cmp(dec"123.456000000000E789", dec"123.456E789") == 0 - # com475 - @test cmp(dec"123.45600000000E-89", dec"123.456E-89") == 0 - # com476 - @test cmp(dec"123.4560000000E789", dec"123.456E789") == 0 - # com477 - @test cmp(dec"123.456000000E-89", dec"123.456E-89") == 0 - # com478 - @test cmp(dec"123.45600000E789", dec"123.456E789") == 0 - # com479 - @test cmp(dec"123.4560000E-89", dec"123.456E-89") == 0 - # com480 - @test cmp(dec"123.456000E789", dec"123.456E789") == 0 - # com481 - @test cmp(dec"123.45600E-89", dec"123.456E-89") == 0 - # com482 - @test cmp(dec"123.4560E789", dec"123.456E789") == 0 - # com483 - @test cmp(dec"123.456E-89", dec"123.456E-89") == 0 - # com484 - @test cmp(dec"123.456E-89", dec"123.4560000000000000E-89") == 0 - # com485 - @test cmp(dec"123.456E789", dec"123.456000000000000E789") == 0 - # com486 - @test cmp(dec"123.456E-89", dec"123.45600000000000E-89") == 0 - # com487 - @test cmp(dec"123.456E789", dec"123.4560000000000E789") == 0 - # com488 - @test cmp(dec"123.456E-89", dec"123.456000000000E-89") == 0 - # com489 - @test cmp(dec"123.456E789", dec"123.45600000000E789") == 0 - # com490 - @test cmp(dec"123.456E-89", dec"123.4560000000E-89") == 0 - # com491 - @test cmp(dec"123.456E789", dec"123.456000000E789") == 0 - # com492 - @test cmp(dec"123.456E-89", dec"123.45600000E-89") == 0 - # com493 - @test cmp(dec"123.456E789", dec"123.4560000E789") == 0 - # com494 - @test cmp(dec"123.456E-89", dec"123.456000E-89") == 0 - # com495 - @test cmp(dec"123.456E789", dec"123.45600E789") == 0 - # com496 - @test cmp(dec"123.456E-89", dec"123.4560E-89") == 0 - # com497 - @test cmp(dec"123.456E789", dec"123.456E789") == 0 - # com500 - @test cmp(dec"1", dec"1E-15") == 1 - # com501 - @test cmp(dec"1", dec"1E-14") == 1 - # com502 - @test cmp(dec"1", dec"1E-13") == 1 - # com503 - @test cmp(dec"1", dec"1E-12") == 1 - # com504 - @test cmp(dec"1", dec"1E-11") == 1 - # com505 - @test cmp(dec"1", dec"1E-10") == 1 - # com506 - @test cmp(dec"1", dec"1E-9") == 1 - # com507 - @test cmp(dec"1", dec"1E-8") == 1 - # com508 - @test cmp(dec"1", dec"1E-7") == 1 - # com509 - @test cmp(dec"1", dec"1E-6") == 1 - # com510 - @test cmp(dec"1", dec"1E-5") == 1 - # com511 - @test cmp(dec"1", dec"1E-4") == 1 - # com512 - @test cmp(dec"1", dec"1E-3") == 1 - # com513 - @test cmp(dec"1", dec"1E-2") == 1 - # com514 - @test cmp(dec"1", dec"1E-1") == 1 - # com515 - @test cmp(dec"1", dec"1E-0") == 0 - # com516 - @test cmp(dec"1", dec"1E+1") == -1 - # com517 - @test cmp(dec"1", dec"1E+2") == -1 - # com518 - @test cmp(dec"1", dec"1E+3") == -1 - # com519 - @test cmp(dec"1", dec"1E+4") == -1 - # com521 - @test cmp(dec"1", dec"1E+5") == -1 - # com522 - @test cmp(dec"1", dec"1E+6") == -1 - # com523 - @test cmp(dec"1", dec"1E+7") == -1 - # com524 - @test cmp(dec"1", dec"1E+8") == -1 - # com525 - @test cmp(dec"1", dec"1E+9") == -1 - # com526 - @test cmp(dec"1", dec"1E+10") == -1 - # com527 - @test cmp(dec"1", dec"1E+11") == -1 - # com528 - @test cmp(dec"1", dec"1E+12") == -1 - # com529 - @test cmp(dec"1", dec"1E+13") == -1 - # com530 - @test cmp(dec"1", dec"1E+14") == -1 - # com531 - @test cmp(dec"1", dec"1E+15") == -1 - # com540 - @test cmp(dec"1E-15", dec"1") == -1 - # com541 - @test cmp(dec"1E-14", dec"1") == -1 - # com542 - @test cmp(dec"1E-13", dec"1") == -1 - # com543 - @test cmp(dec"1E-12", dec"1") == -1 - # com544 - @test cmp(dec"1E-11", dec"1") == -1 - # com545 - @test cmp(dec"1E-10", dec"1") == -1 - # com546 - @test cmp(dec"1E-9", dec"1") == -1 - # com547 - @test cmp(dec"1E-8", dec"1") == -1 - # com548 - @test cmp(dec"1E-7", dec"1") == -1 - # com549 - @test cmp(dec"1E-6", dec"1") == -1 - # com550 - @test cmp(dec"1E-5", dec"1") == -1 - # com551 - @test cmp(dec"1E-4", dec"1") == -1 - # com552 - @test cmp(dec"1E-3", dec"1") == -1 - # com553 - @test cmp(dec"1E-2", dec"1") == -1 - # com554 - @test cmp(dec"1E-1", dec"1") == -1 - # com555 - @test cmp(dec"1E-0", dec"1") == 0 - # com556 - @test cmp(dec"1E+1", dec"1") == 1 - # com557 - @test cmp(dec"1E+2", dec"1") == 1 - # com558 - @test cmp(dec"1E+3", dec"1") == 1 - # com559 - @test cmp(dec"1E+4", dec"1") == 1 - # com561 - @test cmp(dec"1E+5", dec"1") == 1 - # com562 - @test cmp(dec"1E+6", dec"1") == 1 - # com563 - @test cmp(dec"1E+7", dec"1") == 1 - # com564 - @test cmp(dec"1E+8", dec"1") == 1 - # com565 - @test cmp(dec"1E+9", dec"1") == 1 - # com566 - @test cmp(dec"1E+10", dec"1") == 1 - # com567 - @test cmp(dec"1E+11", dec"1") == 1 - # com568 - @test cmp(dec"1E+12", dec"1") == 1 - # com569 - @test cmp(dec"1E+13", dec"1") == 1 - # com570 - @test cmp(dec"1E+14", dec"1") == 1 - # com571 - @test cmp(dec"1E+15", dec"1") == 1 - # com580 - @test cmp(dec"0.000000987654321", dec"1E-15") == 1 - # com581 - @test cmp(dec"0.000000987654321", dec"1E-14") == 1 - # com582 - @test cmp(dec"0.000000987654321", dec"1E-13") == 1 - # com583 - @test cmp(dec"0.000000987654321", dec"1E-12") == 1 - # com584 - @test cmp(dec"0.000000987654321", dec"1E-11") == 1 - # com585 - @test cmp(dec"0.000000987654321", dec"1E-10") == 1 - # com586 - @test cmp(dec"0.000000987654321", dec"1E-9") == 1 - # com587 - @test cmp(dec"0.000000987654321", dec"1E-8") == 1 - # com588 - @test cmp(dec"0.000000987654321", dec"1E-7") == 1 - # com589 - @test cmp(dec"0.000000987654321", dec"1E-6") == -1 - # com590 - @test cmp(dec"0.000000987654321", dec"1E-5") == -1 - # com591 - @test cmp(dec"0.000000987654321", dec"1E-4") == -1 - # com592 - @test cmp(dec"0.000000987654321", dec"1E-3") == -1 - # com593 - @test cmp(dec"0.000000987654321", dec"1E-2") == -1 - # com594 - @test cmp(dec"0.000000987654321", dec"1E-1") == -1 - # com595 - @test cmp(dec"0.000000987654321", dec"1E-0") == -1 - # com596 - @test cmp(dec"0.000000987654321", dec"1E+1") == -1 - # com597 - @test cmp(dec"0.000000987654321", dec"1E+2") == -1 - # com598 - @test cmp(dec"0.000000987654321", dec"1E+3") == -1 - # com599 - @test cmp(dec"0.000000987654321", dec"1E+4") == -1 - # com600 - @test cmp(dec"12", dec"12.2345") == -1 - # com601 - @test cmp(dec"12.0", dec"12.2345") == -1 - # com602 - @test cmp(dec"12.00", dec"12.2345") == -1 - # com603 - @test cmp(dec"12.000", dec"12.2345") == -1 - # com604 - @test cmp(dec"12.0000", dec"12.2345") == -1 - # com605 - @test cmp(dec"12.00000", dec"12.2345") == -1 - # com606 - @test cmp(dec"12.000000", dec"12.2345") == -1 - # com607 - @test cmp(dec"12.0000000", dec"12.2345") == -1 - # com608 - @test cmp(dec"12.00000000", dec"12.2345") == -1 - # com609 - @test cmp(dec"12.000000000", dec"12.2345") == -1 - # com610 - @test cmp(dec"12.1234", dec"12") == 1 - # com611 - @test cmp(dec"12.1234", dec"12.0") == 1 - # com612 - @test cmp(dec"12.1234", dec"12.00") == 1 - # com613 - @test cmp(dec"12.1234", dec"12.000") == 1 - # com614 - @test cmp(dec"12.1234", dec"12.0000") == 1 - # com615 - @test cmp(dec"12.1234", dec"12.00000") == 1 - # com616 - @test cmp(dec"12.1234", dec"12.000000") == 1 - # com617 - @test cmp(dec"12.1234", dec"12.0000000") == 1 - # com618 - @test cmp(dec"12.1234", dec"12.00000000") == 1 - # com619 - @test cmp(dec"12.1234", dec"12.000000000") == 1 - # com620 - @test cmp(dec"-12", dec"-12.2345") == 1 - # com621 - @test cmp(dec"-12.0", dec"-12.2345") == 1 - # com622 - @test cmp(dec"-12.00", dec"-12.2345") == 1 - # com623 - @test cmp(dec"-12.000", dec"-12.2345") == 1 - # com624 - @test cmp(dec"-12.0000", dec"-12.2345") == 1 - # com625 - @test cmp(dec"-12.00000", dec"-12.2345") == 1 - # com626 - @test cmp(dec"-12.000000", dec"-12.2345") == 1 - # com627 - @test cmp(dec"-12.0000000", dec"-12.2345") == 1 - # com628 - @test cmp(dec"-12.00000000", dec"-12.2345") == 1 - # com629 - @test cmp(dec"-12.000000000", dec"-12.2345") == 1 - # com630 - @test cmp(dec"-12.1234", dec"-12") == -1 - # com631 - @test cmp(dec"-12.1234", dec"-12.0") == -1 - # com632 - @test cmp(dec"-12.1234", dec"-12.00") == -1 - # com633 - @test cmp(dec"-12.1234", dec"-12.000") == -1 - # com634 - @test cmp(dec"-12.1234", dec"-12.0000") == -1 - # com635 - @test cmp(dec"-12.1234", dec"-12.00000") == -1 - # com636 - @test cmp(dec"-12.1234", dec"-12.000000") == -1 - # com637 - @test cmp(dec"-12.1234", dec"-12.0000000") == -1 - # com638 - @test cmp(dec"-12.1234", dec"-12.00000000") == -1 - # com639 - @test cmp(dec"-12.1234", dec"-12.000000000") == -1 - # com680 - @test cmp(dec"12", dec"12") == 0 - # com681 - @test cmp(dec"12", dec"12.0") == 0 - # com682 - @test cmp(dec"12", dec"12.00") == 0 - # com683 - @test cmp(dec"12", dec"12.000") == 0 - # com684 - @test cmp(dec"12", dec"12.0000") == 0 - # com685 - @test cmp(dec"12", dec"12.00000") == 0 - # com686 - @test cmp(dec"12", dec"12.000000") == 0 - # com687 - @test cmp(dec"12", dec"12.0000000") == 0 - # com688 - @test cmp(dec"12", dec"12.00000000") == 0 - # com689 - @test cmp(dec"12", dec"12.000000000") == 0 - # com690 - @test cmp(dec"12", dec"12") == 0 - # com691 - @test cmp(dec"12.0", dec"12") == 0 - # com692 - @test cmp(dec"12.00", dec"12") == 0 - # com693 - @test cmp(dec"12.000", dec"12") == 0 - # com694 - @test cmp(dec"12.0000", dec"12") == 0 - # com695 - @test cmp(dec"12.00000", dec"12") == 0 - # com696 - @test cmp(dec"12.000000", dec"12") == 0 - # com697 - @test cmp(dec"12.0000000", dec"12") == 0 - # com698 - @test cmp(dec"12.00000000", dec"12") == 0 - # com699 - @test cmp(dec"12.000000000", dec"12") == 0 - # com701 - @test cmp(dec"12345678000", dec"1") == 1 - # com702 - @test cmp(dec"1", dec"12345678000") == -1 - # com703 - @test cmp(dec"1234567800", dec"1") == 1 - # com704 - @test cmp(dec"1", dec"1234567800") == -1 - # com705 - @test cmp(dec"1234567890", dec"1") == 1 - # com706 - @test cmp(dec"1", dec"1234567890") == -1 - # com707 - @test cmp(dec"1234567891", dec"1") == 1 - # com708 - @test cmp(dec"1", dec"1234567891") == -1 - # com709 - @test cmp(dec"12345678901", dec"1") == 1 - # com710 - @test cmp(dec"1", dec"12345678901") == -1 - # com711 - @test cmp(dec"1234567896", dec"1") == 1 - # com712 - @test cmp(dec"1", dec"1234567896") == -1 - # com713 - @test cmp(dec"-1234567891", dec"1") == -1 - # com714 - @test cmp(dec"1", dec"-1234567891") == 1 - # com715 - @test cmp(dec"-12345678901", dec"1") == -1 - # com716 - @test cmp(dec"1", dec"-12345678901") == 1 - # com717 - @test cmp(dec"-1234567896", dec"1") == -1 - # com718 - @test cmp(dec"1", dec"-1234567896") == 1 - # com741 - @test cmp(dec"12345678000", dec"1") == 1 - # com742 - @test cmp(dec"1", dec"12345678000") == -1 - # com743 - @test cmp(dec"1234567800", dec"1") == 1 - # com744 - @test cmp(dec"1", dec"1234567800") == -1 - # com745 - @test cmp(dec"1234567890", dec"1") == 1 - # com746 - @test cmp(dec"1", dec"1234567890") == -1 - # com747 - @test cmp(dec"1234567891", dec"1") == 1 - # com748 - @test cmp(dec"1", dec"1234567891") == -1 - # com749 - @test cmp(dec"12345678901", dec"1") == 1 - # com750 - @test cmp(dec"1", dec"12345678901") == -1 - # com751 - @test cmp(dec"1234567896", dec"1") == 1 - # com752 - @test cmp(dec"1", dec"1234567896") == -1 -end diff --git a/test/test_context.jl b/test/test_context.jl new file mode 100644 index 0000000..fb6eb35 --- /dev/null +++ b/test/test_context.jl @@ -0,0 +1,12 @@ +using Decimals +using Test + +@testset "Context" begin + setprecision(Decimal, 3) + Decimals.CONTEXT.Emax = 9 + x = Decimal(0, 123, 7) + @test x == Decimals.fix(x) + + x = Decimal(0, 123, 8) + @test_throws OverflowError Decimals.fix(x) +end