changeset 3:bfda0b347c07

Initial development of BCD integers
author Paul (paul.d.anderson@comcast.net)
date Thu, 18 Mar 2010 18:09:20 -0700
parents abf9d7974708
children b37c218c1442
files src/decimal/decimal.d
diffstat 1 files changed, 9 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/decimal/decimal.d	Sat Mar 13 18:52:56 2010 -0800
+++ b/src/decimal/decimal.d	Thu Mar 18 18:09:20 2010 -0700
@@ -2042,6 +2042,7 @@
 		return addend;
 	}
 	
+//	writeln("aligning");
 	// align the operands
 	alignOps(augend, addend);
 
@@ -2058,11 +2059,17 @@
 	
 	// if operands have the same sign...
 	if (augend.sign == addend.sign) {
+//		writeln("same sign");
+//		writeln("augend = ", augend.ceff);
+//		writeln("addend = ", addend.ceff);
 		sum.ceff = augend.ceff + addend.ceff;
+//		writeln("sum = ", sum.ceff);
 		sum.sign = augend.sign;
+//		writeln("set sign");
 	}
 	// ...else operands have different signs
 	else {
+//		writeln("signs differ");
 		sum.ceff = augend.ceff - addend.ceff;
 		sum.sign = augend.sign;
 		if (sum.ceff < BIG_ZERO) {
@@ -2074,8 +2081,10 @@
 	sum.digits = numDigits(sum.ceff, augend.digits);
 	sum.expo = augend.expo;
 	
+//	writeln("rounding");
 	// round the result
 	round(sum);
+//	writeln("rounded");
 	return sum;
 }	// end add(augend, addend)
 
@@ -3224,50 +3233,4 @@
 	writeln("passed");
 }
 	
-public void main() {
-	writeln("Hello, world!");
-/+	writeln("eTiny = ", context.eTiny);
-	writeln("tiny min = ", Decimal(1, context.eTiny));
-	writeln("tiny min = ", Decimal(1, context.eTiny - 1));
-	writeln("max = ", context.max());
-	writeln("max1 = ", Decimal(999999999, 99));
-	writeln("dig = ", context.dig());
-	writeln("eps = ", context.epsilon());
-	writeln("smallest = ", context.min_normal()*context.epsilon());
-	writeln("1/epsilon = ", Decimal(1)/context.epsilon());
-	writeln("max * min = ", context.max * context.min_normal);
-	writeln("mant_dig = ", context.mant_dig);
-	writeln("min_exp = ", context.min_exp);
-	writeln("max_exp = ", context.max_exp);+/
-	
-	
-    // TODO: this next one goes crazy -- shows need for checks on construction
-	// TODO: turns out this is being converted to a double (or real) and
-	// then it's really weird.
-//	writeln("bigger = ", Decimal(999999999999));
-//	float f = float.max;
-	// TODO: convert these to assserts
-/+	writeln("f.max = ", f);
-	writeln("f.min = ", float.min);
-	writeln("f = ", 2 * float.min);
-	writeln("d.max = ", Decimal.max());
-	writeln("d.min = ", Decimal.min_normal());
-	writeln("2 * d.min = ", 2 * Decimal.min_normal());
-	writeln("0.1 * d.min = ", 0.1 * Decimal.min_normal());+/
-	// TODO: move this to unittesting
-/+	Decimal dec = Decimal(PI);
-	writeln("pi = ", dec );
-	dec = Decimal(PI, 19);
-	writeln("pi = ", dec );
-	dec = Decimal(1.3, 25);
-	writeln("pi = ", dec );
-	dec = Decimal(0.1, 25);
-	writeln("pi = ", dec );
-	dec = Decimal(2.0, 25);
-	writeln("pi = ", dec );
-	dec = Decimal(200.5, 25);
-	writeln("pi = ", dec );
-	writeln(double.dig);
-	writeln(real.dig);+/
-}