From 2327d8ff58332c09d82de17b8cdd119d6cef56b4 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 18 Jun 2014 18:42:28 +0100 Subject: 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. --- Source/Basetypes/BigDec.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Source/Basetypes') 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) { -- cgit v1.2.3