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
7886965e
Commit
7886965e
authored
Mar 08, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug in dtoa
This previously affects Writer:: SetMaxDecimalPlaces()
parent
824120b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
dtoa.h
include/rapidjson/internal/dtoa.h
+1
-1
dtoatest.cpp
test/unittest/dtoatest.cpp
+6
-0
No files found.
include/rapidjson/internal/dtoa.h
View file @
7886965e
...
...
@@ -180,7 +180,7 @@ inline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) {
buffer
[
1
]
=
'.'
;
for
(
int
i
=
2
;
i
<
offset
;
i
++
)
buffer
[
i
]
=
'0'
;
if
(
length
+
offset
>
maxDecimalPlaces
)
{
if
(
length
-
kk
>
maxDecimalPlaces
)
{
// When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1
// Remove extra trailing zeros (at least one) after truncation.
for
(
int
i
=
maxDecimalPlaces
+
1
;
i
>
2
;
i
--
)
...
...
test/unittest/dtoatest.cpp
View file @
7886965e
...
...
@@ -81,6 +81,12 @@ TEST(dtoa, maxDecimalPlaces) {
TEST_DTOA
(
3
,
2.225073858507201e-308
,
"0.0"
);
// Max subnormal positive double
TEST_DTOA
(
3
,
2.2250738585072014e-308
,
"0.0"
);
// Min normal positive double
TEST_DTOA
(
3
,
1.7976931348623157e308
,
"1.7976931348623157e308"
);
// Max double
TEST_DTOA
(
5
,
-
0.14000000000000001
,
"-0.14"
);
TEST_DTOA
(
4
,
-
0.14000000000000001
,
"-0.14"
);
TEST_DTOA
(
3
,
-
0.14000000000000001
,
"-0.14"
);
TEST_DTOA
(
3
,
-
0.10000000000000001
,
"-0.1"
);
TEST_DTOA
(
2
,
-
0.10000000000000001
,
"-0.1"
);
TEST_DTOA
(
1
,
-
0.10000000000000001
,
"-0.1"
);
#undef TEST_DTOA
}
...
...
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