"git@developer.sourcefind.cn:cnjsdfcy/simbricks.git" did not exist on "05de0b1d1e9d3ecb5ff8c09772ad44e72a72dd7a"
Commit e0ae477b authored by Jesse Beder's avatar Jesse Beder
Browse files

Switch default precision to one more than the number of digits allows.

See, e.g., http://stackoverflow.com/questions/4738768/printing-double-without-losing-precision.
parent 8c517bf0
...@@ -19,8 +19,8 @@ namespace YAML ...@@ -19,8 +19,8 @@ namespace YAML
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(6); m_floatPrecision.set(std::numeric_limits<float>::digits10 + 1);
m_doublePrecision.set(15); m_doublePrecision.set(std::numeric_limits<double>::digits10 + 1);
} }
EmitterState::~EmitterState() EmitterState::~EmitterState()
...@@ -367,7 +367,7 @@ namespace YAML ...@@ -367,7 +367,7 @@ namespace YAML
bool EmitterState::SetFloatPrecision(int value, FmtScope::value scope) bool EmitterState::SetFloatPrecision(int value, FmtScope::value scope)
{ {
if(value < 0 || value > std::numeric_limits<float>::digits10) if(value < 0 || value > std::numeric_limits<float>::digits10 + 1)
return false; return false;
_Set(m_floatPrecision, value, scope); _Set(m_floatPrecision, value, scope);
return true; return true;
...@@ -375,7 +375,7 @@ namespace YAML ...@@ -375,7 +375,7 @@ namespace YAML
bool EmitterState::SetDoublePrecision(int value, FmtScope::value scope) bool EmitterState::SetDoublePrecision(int value, FmtScope::value scope)
{ {
if(value < 0 || value > std::numeric_limits<double>::digits10) if(value < 0 || value > std::numeric_limits<double>::digits10 + 1)
return false; return false;
_Set(m_doublePrecision, value, scope); _Set(m_doublePrecision, value, scope);
return true; return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment