Fix tiny bug in double 2 string formatting
- I forgot to handle the trailing dots when I added the fmt variant - UIDouble2Str (the original) lacked the comma check - Add unit test lol
This commit is contained in:
@@ -1104,11 +1104,18 @@ std::string FormatDouble2Str( double aValue )
|
||||
{
|
||||
buf = fmt::format( "{:.16f}", aValue );
|
||||
|
||||
// remove trailing zeros
|
||||
// remove trailing zeros (and the decimal marker if needed)
|
||||
while( !buf.empty() && buf[buf.size() - 1] == '0' )
|
||||
{
|
||||
buf.pop_back();
|
||||
}
|
||||
|
||||
// if the value was really small
|
||||
// we may have just stripped all the zeros after the decimal
|
||||
if( buf[buf.size() - 1] == '.' )
|
||||
{
|
||||
buf.pop_back();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1133,7 +1140,7 @@ std::string UIDouble2Str( double aValue )
|
||||
while( --len > 0 && buf[len] == '0' )
|
||||
buf[len] = '\0';
|
||||
|
||||
if( buf[len] == '.' )
|
||||
if( buf[len] == '.' || buf[len] == ',' )
|
||||
buf[len] = '\0';
|
||||
else
|
||||
++len;
|
||||
|
||||
Reference in New Issue
Block a user