Skip to content

Conversation

floork
Copy link

@floork floork commented Nov 8, 2024

shows the displayExpression in prefix notation

fixes: #4

@bmario
Copy link
Member

bmario commented Jan 24, 2025

Please rebase, so the CI can run.

@floork floork force-pushed the displayExpression branch from 2150da0 to a02a981 Compare January 27, 2025 07:13
@floork floork force-pushed the displayExpression branch from 2c47091 to 5fab0d1 Compare January 27, 2025 14:38
Comment on lines 59 to 76
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;
Copy link
Member

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename display_expression to displayExpression
2 participants