# andersonpd/decimal

moved digits functionality into rounding

1 parent 825198a commit e3ee06bfaaf08195dd2c92c3a3a7e4c5b8829082 committed Jun 16, 2011
Showing with 744 additions and 187 deletions.
1. +1 −1 decimal/arithmetic.d
2. +13 −3 decimal/bid.d
3. +1 −1 decimal/decimal.d
4. +2 −1 decimal/digits.d
5. +1 −1 decimal/logical.d
6. +1 −1 decimal/math.d
7. +724 −178 decimal/rounding.d
8. +1 −1 decimal/test.d
 @@ -29,7 +29,7 @@ module decimal.arithmetic; import decimal.context; -import decimal.digits; +//import decimal.digits; import decimal.decimal; import decimal.rounding; import std.array: insertInPlace;
 @@ -17,16 +17,21 @@ module decimal.bid; -import decimal.decimal; import std.array: insertInPlace; import std.bigint; import std.bitmanip; import std.conv; import std.stdio; import std.string; +import decimal.context; +import decimal.decimal; +import decimal.rounding; + struct Dec32 { + private static context = DEFAULT_CONTEXT.dup; + /// The number of bits in the signed value of the decimal number. /// This is equal to the number of bits in the underlying integer; /// (must be 32, 64, or 128). @@ -357,8 +362,13 @@ struct Dec32 { */ public this(const long n) { signed = n < 0; - expoEx = 0; - mantEx = cast(uint) std.math.abs(n); + int expo = 0; + long mant = std.math.abs(n); + if (mant > MAX_IMPL) { + expo = setExponent(mant, context); + } + expoEx = expo; + mantEx = cast(uint) mant; } /**
 @@ -29,7 +29,7 @@ module decimal.decimal; import decimal.context; -import decimal.digits; +import decimal.rounding; import decimal.arithmetic; import std.bigint; import std.exception: assumeUnique;
 @@ -18,6 +18,7 @@ module decimal.digits; +/+ import std.bigint; import std.conv; import std.stdio: write, writeln; @@ -579,5 +580,5 @@ unittest { writeln("-------------------"); writeln(); } - ++/
 @@ -19,7 +19,7 @@ module decimal.logical; import decimal.decimal; import decimal.context; -import decimal.digits; +//import decimal.digits; import decimal.arithmetic;
 @@ -20,7 +20,7 @@ module decimal.math; import decimal.decimal; import decimal.context; -import decimal.digits; +//import decimal.digits; import decimal.rounding; import decimal.arithmetic; //import std.math;