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
c1f5f045
Commit
c1f5f045
authored
Jan 24, 2016
by
Trevor Welsby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add workaround for gcc < 5 not supporting std::defaultfloat
parent
bd8db5d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
json.hpp
src/json.hpp
+4
-1
json.hpp.re2c
src/json.hpp.re2c
+4
-1
No files found.
src/json.hpp
View file @
c1f5f045
...
@@ -5544,7 +5544,10 @@ class basic_json
...
@@ -5544,7 +5544,10 @@ class basic_json
// 15 digits of precision allows round-trip IEEE 754 string->double->string;
// 15 digits of precision allows round-trip IEEE 754 string->double->string;
// to be safe, we read this value from std::numeric_limits<number_float_t>::digits10
// to be safe, we read this value from std::numeric_limits<number_float_t>::digits10
if
(
std
::
fmod
(
m_value
.
number_float
,
1
)
==
0
)
o
<<
std
::
fixed
<<
std
::
setprecision
(
1
);
if
(
std
::
fmod
(
m_value
.
number_float
,
1
)
==
0
)
o
<<
std
::
fixed
<<
std
::
setprecision
(
1
);
else
o
<<
std
::
defaultfloat
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
);
else
{
o
.
unsetf
(
std
::
ios_base
::
floatfield
);
// std::defaultfloat not supported in gcc version < 5
o
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
);
}
o
<<
m_value
.
number_float
;
o
<<
m_value
.
number_float
;
return
;
return
;
}
}
...
...
src/json.hpp.re2c
View file @
c1f5f045
...
@@ -5544,7 +5544,10 @@ class basic_json
...
@@ -5544,7 +5544,10 @@ class basic_json
// 15 digits of precision allows round-trip IEEE 754 string->double->string;
// 15 digits of precision allows round-trip IEEE 754 string->double->string;
// to be safe, we read this value from std::numeric_limits<number_float_t>::digits10
// to be safe, we read this value from std::numeric_limits<number_float_t>::digits10
if (std::fmod(m_value.number_float, 1) == 0) o << std::fixed << std::setprecision(1);
if (std::fmod(m_value.number_float, 1) == 0) o << std::fixed << std::setprecision(1);
else o << std::defaultfloat << std::setprecision(std::numeric_limits<double>::digits10);
else {
o.unsetf(std::ios_base::floatfield); // std::defaultfloat not supported in gcc version < 5
o << std::setprecision(std::numeric_limits<double>::digits10);
}
o << m_value.number_float;
o << m_value.number_float;
return;
return;
}
}
...
...
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