Fix float precision
Replaced
std::numeric_limits<T>::digits10 + 1
with
std::numeric_limits<T>::max_digits10
everywhere.
This commit is contained in:
parent
bedb28fdb4
commit
bb3b109101
@ -76,7 +76,7 @@ struct convert<const char*> {
|
|||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
struct convert<const char[N]> {
|
struct convert<const char[N]> {
|
||||||
static Node encode(const char(&rhs)[N]) { return Node(rhs); }
|
static Node encode(const char (&rhs)[N]) { return Node(rhs); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -93,7 +93,7 @@ struct convert<_Null> {
|
|||||||
struct convert<type> { \
|
struct convert<type> { \
|
||||||
static Node encode(const type& rhs) { \
|
static Node encode(const type& rhs) { \
|
||||||
std::stringstream stream; \
|
std::stringstream stream; \
|
||||||
stream.precision(std::numeric_limits<type>::digits10 + 1); \
|
stream.precision(std::numeric_limits<type>::max_digits10); \
|
||||||
stream << rhs; \
|
stream << rhs; \
|
||||||
return Node(stream.str()); \
|
return Node(stream.str()); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@ -24,8 +24,8 @@ EmitterState::EmitterState()
|
|||||||
m_seqFmt.set(Block);
|
m_seqFmt.set(Block);
|
||||||
m_mapFmt.set(Block);
|
m_mapFmt.set(Block);
|
||||||
m_mapKeyFmt.set(Auto);
|
m_mapKeyFmt.set(Auto);
|
||||||
m_floatPrecision.set(std::numeric_limits<float>::digits10 + 1);
|
m_floatPrecision.set(std::numeric_limits<float>::max_digits10);
|
||||||
m_doublePrecision.set(std::numeric_limits<double>::digits10 + 1);
|
m_doublePrecision.set(std::numeric_limits<double>::max_digits10);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmitterState::~EmitterState() {}
|
EmitterState::~EmitterState() {}
|
||||||
@ -349,7 +349,7 @@ bool EmitterState::SetMapKeyFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EmitterState::SetFloatPrecision(std::size_t value, FmtScope::value scope) {
|
bool EmitterState::SetFloatPrecision(std::size_t value, FmtScope::value scope) {
|
||||||
if (value > std::numeric_limits<float>::digits10 + 1)
|
if (value > std::numeric_limits<float>::max_digits10)
|
||||||
return false;
|
return false;
|
||||||
_Set(m_floatPrecision, value, scope);
|
_Set(m_floatPrecision, value, scope);
|
||||||
return true;
|
return true;
|
||||||
@ -357,7 +357,7 @@ bool EmitterState::SetFloatPrecision(std::size_t value, FmtScope::value scope) {
|
|||||||
|
|
||||||
bool EmitterState::SetDoublePrecision(std::size_t value,
|
bool EmitterState::SetDoublePrecision(std::size_t value,
|
||||||
FmtScope::value scope) {
|
FmtScope::value scope) {
|
||||||
if (value > std::numeric_limits<double>::digits10 + 1)
|
if (value > std::numeric_limits<double>::max_digits10)
|
||||||
return false;
|
return false;
|
||||||
_Set(m_doublePrecision, value, scope);
|
_Set(m_doublePrecision, value, scope);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user