Permalink
Browse files

support -0.0 for issue #147

  • Loading branch information...
1 parent 432465a commit d863525a9e2667af54f8addfbf194c0ec8dfff84 @Cary Cary committed with Sep 25, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −1 Classes/SBJsonTokeniser.m
  2. +2 −1 Tests/Data/valid/number/float/input
  3. +1 −1 Tests/Data/valid/number/float/output
@@ -367,7 +367,8 @@ - (sbjson_token_t)getNumberToken:(NSObject**)token {
if (mantissa_length <= LONG_LONG_DIGITS) {
if (!isFloat && !hasExponent) {
*token = [NSNumber numberWithLongLong: isNegative ? -mantissa : mantissa];
-
+ } else if (mantissa == 0) {
+ *token = [NSNumber numberWithInt:0];
} else {
*token = [NSDecimalNumber decimalNumberWithMantissa:mantissa
exponent:exponent
@@ -3,5 +3,6 @@
2.5,
4.4,
99.99,
-720.17300000000000182
+720.17300000000000182,
+-0.0000
]
@@ -1 +1 @@
-[0.0001,2.5,4.4,99.99,720.17300000000000182]
+[0.0001,2.5,4.4,99.99,720.17300000000000182,0]

0 comments on commit d863525

Please sign in to comment.