Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
9b9919d4
Commit
9b9919d4
authored
Jan 15, 2018
by
abolz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use max_digits10 in dump_float for float->text->float round-trip
parent
810f81bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
serializer.hpp
develop/detail/serializer.hpp
+2
-2
json.hpp
src/json.hpp
+2
-2
No files found.
develop/detail/serializer.hpp
View file @
9b9919d4
...
@@ -665,8 +665,8 @@ class serializer
...
@@ -665,8 +665,8 @@ class serializer
void
dump_float
(
number_float_t
x
,
std
::
false_type
/*is_ieee_single_or_double*/
)
void
dump_float
(
number_float_t
x
,
std
::
false_type
/*is_ieee_single_or_double*/
)
{
{
// get number of digits for a
text -> float -> tex
t round-trip
// get number of digits for a
float -> text -> floa
t round-trip
static
constexpr
auto
d
=
std
::
numeric_limits
<
number_float_t
>::
digits10
;
static
constexpr
auto
d
=
std
::
numeric_limits
<
number_float_t
>::
max_
digits10
;
// the actual conversion
// the actual conversion
std
::
ptrdiff_t
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
std
::
ptrdiff_t
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
...
...
src/json.hpp
View file @
9b9919d4
...
@@ -8136,8 +8136,8 @@ class serializer
...
@@ -8136,8 +8136,8 @@ class serializer
void
dump_float
(
number_float_t
x
,
std
::
false_type
/*is_ieee_single_or_double*/
)
void
dump_float
(
number_float_t
x
,
std
::
false_type
/*is_ieee_single_or_double*/
)
{
{
// get number of digits for a
text -> float -> tex
t round-trip
// get number of digits for a
float -> text -> floa
t round-trip
static
constexpr
auto
d
=
std
::
numeric_limits
<
number_float_t
>::
digits10
;
static
constexpr
auto
d
=
std
::
numeric_limits
<
number_float_t
>::
max_
digits10
;
// the actual conversion
// the actual conversion
std
::
ptrdiff_t
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
std
::
ptrdiff_t
len
=
snprintf
(
number_buffer
.
data
(),
number_buffer
.
size
(),
"%.*g"
,
d
,
x
);
...
...
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