mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 15:39:41 +00:00
Implement 'g' flag
This commit is contained in:
parent
579f35511a
commit
1c49698053
3 changed files with 28 additions and 3 deletions
|
@ -59,11 +59,33 @@ namespace Interpreter
|
||||||
mRuntime.pop();
|
mRuntime.pop();
|
||||||
|
|
||||||
if (notation == FixedNotation)
|
if (notation == FixedNotation)
|
||||||
|
{
|
||||||
out << std::fixed << value;
|
out << std::fixed << value;
|
||||||
else
|
mFormattedMessage += out.str();
|
||||||
|
}
|
||||||
|
else if (notation == ShortestNotation)
|
||||||
|
{
|
||||||
|
std::string scientific;
|
||||||
|
std::string fixed;
|
||||||
|
|
||||||
out << std::scientific << value;
|
out << std::scientific << value;
|
||||||
|
|
||||||
mFormattedMessage += out.str();
|
scientific = out.str();
|
||||||
|
|
||||||
|
out.str(std::string());
|
||||||
|
out.clear();
|
||||||
|
|
||||||
|
out << std::fixed << value;
|
||||||
|
|
||||||
|
fixed = out.str();
|
||||||
|
|
||||||
|
mFormattedMessage += fixed.length() < scientific.length() ? fixed : scientific;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << std::scientific << value;
|
||||||
|
mFormattedMessage += out.str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -56,6 +56,8 @@ namespace Misc
|
||||||
visitedPlaceholder(FloatPlaceholder, pad, width, precision, FixedNotation);
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, FixedNotation);
|
||||||
else if (m[i] == 'e' || m[i] == 'E')
|
else if (m[i] == 'e' || m[i] == 'E')
|
||||||
visitedPlaceholder(FloatPlaceholder, pad, width, precision, ScientificNotation);
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, ScientificNotation);
|
||||||
|
else if (m[i] == 'g' || m[i] == 'G')
|
||||||
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, ShortestNotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace Misc
|
||||||
enum Notation
|
enum Notation
|
||||||
{
|
{
|
||||||
FixedNotation,
|
FixedNotation,
|
||||||
ScientificNotation
|
ScientificNotation,
|
||||||
|
ShortestNotation
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation) = 0;
|
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation) = 0;
|
||||||
|
|
Loading…
Reference in a new issue