Merge to fix default precision for floats.

This commit is contained in:
Jesse Beder 2013-04-13 00:09:40 -05:00
commit ae42def6cf

View File

@ -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
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
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;