Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
1acfc216
Commit
1acfc216
authored
Jun 30, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #34 from miloyip/SmallFloatingPoint
Fixes parsing small floating point values underflow
parents
2e156cca
4843b790
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
reader.h
include/rapidjson/reader.h
+9
-1
readertest.cpp
test/unittest/readertest.cpp
+2
-2
No files found.
include/rapidjson/reader.h
View file @
1acfc216
...
...
@@ -664,7 +664,15 @@ private:
// Finish parsing, call event according to the type of number.
if
(
useDouble
)
{
d
*=
internal
::
Pow10
(
exp
+
expFrac
);
int
expSum
=
exp
+
expFrac
;
if
(
expSum
<
-
308
)
{
// Prevent expSum < -308, making Pow10(expSum) = 0
d
*=
internal
::
Pow10
(
exp
);
d
*=
internal
::
Pow10
(
expFrac
);
}
else
d
*=
internal
::
Pow10
(
expSum
);
handler
.
Double
(
minus
?
-
d
:
d
);
}
else
{
...
...
test/unittest/readertest.cpp
View file @
1acfc216
...
...
@@ -129,9 +129,9 @@ TEST(Reader, ParseNumberHandler) {
TEST_DOUBLE
(
"1.234E+10"
,
1.234E+10
);
TEST_DOUBLE
(
"1.234E-10"
,
1.234E-10
);
TEST_DOUBLE
(
"1.79769e+308"
,
1.79769e+308
);
//TEST_DOUBLE("2.22507e-308", 2.22507e-308); // TODO: underflow
TEST_DOUBLE
(
"2.22507e-308"
,
2.22507e-308
);
TEST_DOUBLE
(
"-1.79769e+308"
,
-
1.79769e+308
);
//TEST_DOUBLE("-2.22507e-308", -2.22507e-308); // TODO: underflow
TEST_DOUBLE
(
"-2.22507e-308"
,
-
2.22507e-308
);
TEST_DOUBLE
(
"18446744073709551616"
,
18446744073709551616.0
);
// 2^64 (max of uint64_t + 1, force to use double)
TEST_DOUBLE
(
"-9223372036854775809"
,
-
9223372036854775809.0
);
// -2^63 - 1(min of int64_t + 1, force to use double)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment