summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Checkmate50 <dgeisler50@gmail.com>2016-07-23 14:27:23 -0600
committerGravatar Checkmate50 <dgeisler50@gmail.com>2016-07-23 14:27:23 -0600
commit2b64144fb02b68d00188ee81c27afa5fbc026b5b (patch)
tree3cd907500621d3a506444688bda63ae0f521696f
parentf678d42190391708ae09fa68347421da54d9a7b4 (diff)
fixed an error where a -0 was not interpreted as a negative number
-rw-r--r--Source/Basetypes/BigFloat.cs4
-rw-r--r--Test/floats/float13.bpl2
2 files changed, 3 insertions, 3 deletions
diff --git a/Source/Basetypes/BigFloat.cs b/Source/Basetypes/BigFloat.cs
index d27a3b00..cb248340 100644
--- a/Source/Basetypes/BigFloat.cs
+++ b/Source/Basetypes/BigFloat.cs
@@ -144,13 +144,13 @@ namespace Microsoft.Basetypes
exp = BIM.Parse(s.Substring(s.IndexOf('e') + 1, s.IndexOf('f') - s.IndexOf('e') - 1));
sigSize = int.Parse(s.Substring(s.IndexOf('f') + 1, s.IndexOf('e', s.IndexOf('e') + 1) - s.IndexOf('f') - 1));
expSize = int.Parse(s.Substring(s.IndexOf('e', s.IndexOf('e') + 1) + 1));
+ isNeg = s[0] == '-'; //We do this so that -0 is parsed correctly
if (sigSize <= 0 || expSize <= 0)
throw new FormatException("Significand and Exponent sizes must be greater than 0");
sigSize = sigSize - 1; //Get rid of sign bit
- isNeg = sig < 0;
- sig = BIM.Abs(sig);
+ sig = BIM.Abs(sig); //sig must be positive
//Uncomment if you want to shift the exponent for the user (i.e. 0e-1f24e8 --> 0e126f24e8)
//exp = exp + BIM.Pow(new BIM(2), expSize-1) - BIM.One;
diff --git a/Test/floats/float13.bpl b/Test/floats/float13.bpl
index 4aab608a..9c99a30b 100644
--- a/Test/floats/float13.bpl
+++ b/Test/floats/float13.bpl
@@ -17,7 +17,7 @@ procedure main() returns () {
assert(f == fc);
f := -0e126f24e8;
- fc := TO_FLOAT32_REAL(0.5);
+ fc := TO_FLOAT32_REAL(-0.5);
assert(f == fc);
f := 1048576e128f24e8;