-
Notifications
You must be signed in to change notification settings - Fork 0
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
add format_number_no_round
function
#82
Conversation
tests/test_decimal.py
Outdated
(0, "123.456789"), | ||
(2, "123.456789"), |
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.
This throws me.
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.
Ah, yeah.. Not in love with the name of the function, which may go a little ways to explain what the purpose is (beyond, you know, some actual docs....).
For display in a template, I needed a quick way to format a dollar amount to two decimal places without rounding.
E.g.
123.4 -> 123.40
123.45 -> 123.45
123.456 -> 123.456
123.4567 -> 123.4567
123.45670 -> 123.4567
and so on.
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.
Or three decimal places, which is why I added the decimal_places
arg. We have some tracts of land that have fractional acres, but the majority are whole numbers. So I wanted to just show 123 if the acres were 123.000, but 123.456 if the acres were 123.456.
I don't think I've actually pushed that local change actually.
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.
I need to clean it up a bit to clarify things, because even I'm confusing myself thinking through it right now.. 😅
671bb49
to
0a01b41
Compare
format_decimal_places
functionformat_number_no_round
function
for more information, see https://pre-commit.ci
f59209e
to
7a157c7
Compare
No description provided.