Libeval: consistent formatting for NaN
On some platforms like MSVC, NaN prints as "-nan(ind)". This is a bit needlessly ugly, so print "NaN" on all platforms consistently. This fixes a test failure on MSVC.
This commit is contained in:
parent
3b194d6993
commit
dd17f24c04
|
@ -104,8 +104,18 @@ void NUMERIC_EVALUATOR::parseOk()
|
|||
|
||||
void NUMERIC_EVALUATOR::parseSetResult( double val )
|
||||
{
|
||||
if( std::isnan( val ) )
|
||||
{
|
||||
// Naively printing this with %g produces "nan" on some platforms
|
||||
// and "-nan(ind)" on others (e.g. MSVC). So force a "standard" string.
|
||||
snprintf( m_token.token, m_token.OutLen, "%s", "NaN" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can be printed as a floating point
|
||||
snprintf( m_token.token, m_token.OutLen, "%.10g", val );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxString NUMERIC_EVALUATOR::OriginalText() const
|
||||
|
|
|
@ -117,7 +117,7 @@ static const std::vector<EVAL_CASE> eval_cases_valid = {
|
|||
{ "1.5", "1.5" },
|
||||
{ "1,5", "1.5" },
|
||||
// Semicolon is valid, but the result is NaN
|
||||
{ "1;", "nan" },
|
||||
{ "1;", "NaN" },
|
||||
// With own unit
|
||||
{ "1mm", "1" },
|
||||
// Unit that's not the evaluator's unit
|
||||
|
|
Loading…
Reference in New Issue