-
Notifications
You must be signed in to change notification settings - Fork 1
feat(combinator): displayExpression with prefix notation #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Please rebase, so the CI can run. |
2150da0
to
a02a981
Compare
2c47091
to
5fab0d1
Compare
Co-authored-by: Mario Bielert <[email protected]>
src/combinator.cpp
Outdated
const auto value = expression.get<double>(); | ||
|
||
if (std::floor(value) == value) | ||
{ | ||
return std::to_string(static_cast<std::int64_t>(value)); | ||
} | ||
|
||
std::ostringstream oss; | ||
oss << std::fixed << std::setprecision(1) << value; | ||
auto result = oss.str(); | ||
|
||
result.erase(result.find_last_not_of('0') + 1); | ||
if (result.back() == '.') | ||
{ | ||
result.pop_back(); | ||
} | ||
|
||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract that into a function and write tests for it.
100
should be "100"
10.0
should be "10"
10.3
should be "10.3"
10.25
should be "10.25"
0.125
should be "0.125"
0.123456789
should be "0.123456789"
123456789
should be "123456789"
123456789.01234
should be "123456789.01234"
shows the
displayExpression
in prefix notationfixes: #4