diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2014-06-18 18:42:28 +0100 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2014-06-18 18:42:28 +0100 |
commit | 2327d8ff58332c09d82de17b8cdd119d6cef56b4 (patch) | |
tree | 808a60d4a30c7c520216a8a273feb53adc673340 /Source/Basetypes | |
parent | 1c9a1f276a7e878831f2e557cbc3d24a2910e815 (diff) |
Fix bug in BigDec.FromString() which would not parse negative
numbers correctly.
For example BigDec.FromString("-1.5") would be interpreted as
-0.5 due to the incorrect way the method handles the fractional
part of the string.
Diffstat (limited to 'Source/Basetypes')
-rw-r--r-- | Source/Basetypes/BigDec.cs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Source/Basetypes/BigDec.cs b/Source/Basetypes/BigDec.cs index feabb425..4206b2f2 100644 --- a/Source/Basetypes/BigDec.cs +++ b/Source/Basetypes/BigDec.cs @@ -88,7 +88,12 @@ namespace Microsoft.Basetypes { }
}
- return new BigDec(integral + fraction, exponent);
+ if (integral.Sign == -1) {
+ return new BigDec(integral - fraction, exponent);
+ }
+ else {
+ return new BigDec(integral + fraction, exponent);
+ }
}
internal BigDec(BIM mantissa, int exponent) {
|