NUMERIC_EVALUATOR::parseSetResult(): fix incorrect use of %g to print a double.
This function is used in UNIT_BINDER, that does not accept floating notation with exponent, that can be generated by parseSetResult(). As a result: values < 0.0001 cannot be entered in a UNIT_BINDER.
This commit is contained in:
parent
fe6cc0c3d8
commit
7c64dba333
|
@ -81,7 +81,7 @@ std::string Double2Str( double aValue )
|
|||
{
|
||||
// For these values, %g works fine, and sometimes %f
|
||||
// gives a bad value (try aValue = 1.222222222222, with %.16f format!)
|
||||
len = sprintf( buf, "%.16g", aValue );
|
||||
len = sprintf( buf, "%.10g", aValue );
|
||||
}
|
||||
|
||||
return std::string( buf, len );
|
||||
|
@ -437,6 +437,7 @@ void FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits )
|
|||
long long int ValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA_DATA_TYPE aType )
|
||||
{
|
||||
double value = DoubleValueFromString( aUnits, aTextValue, aType );
|
||||
|
||||
return KiROUND<double, long long int>( value );
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,10 @@ void NUMERIC_EVALUATOR::parseSetResult( double val )
|
|||
else
|
||||
{
|
||||
// Can be printed as a floating point
|
||||
snprintf( m_token.token, m_token.OutLen, "%.10g", val );
|
||||
// Warning: DO NOT use a format like %f or %g, because they can create issues.
|
||||
// especially %g can generate an exponent, incompatible with UNIT_BINDER
|
||||
// Use the optimized Double2Str
|
||||
snprintf( m_token.token, m_token.OutLen, "%s", Double2Str( val ).c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue