-
Notifications
You must be signed in to change notification settings - Fork 323
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
Decimal.parse
and .format
#9637
Conversation
Converting this back to draft to explore using |
Decimal.to_text
etc.Decimal.parse
and .format
:w
d.format . should_equal "123,456,789.87654" | ||
d.format locale=Locale.italy . should_equal "123.456.789,87654" | ||
d.format format="#,###.##" . should_equal "123,456,789.88" | ||
d.format format="#,###.##" locale=Locale.italy . should_equal "123.456.789,88" | ||
d.format format="#,##.##" . should_equal "1,23,45,67,89.88" | ||
d.format format="#,##.##" locale=Locale.italy . should_equal "1.23.45.67.89,88" | ||
|
||
group_builder.specify "should parse correctly" <| | ||
Decimal.parse "123456789.87654" . should_equal 123456789.87654 | ||
Decimal.parse "123,456,789.87654" locale=Locale.default . should_equal 123456789.87654 | ||
Decimal.parse "123,456,789.87654" locale=Locale.us . should_equal 123456789.87654 | ||
Decimal.parse "123.456.789,87654" locale=Locale.italy . should_equal 123456789.87654 | ||
Decimal.parse "123,456,789.87654" locale=Locale.italy . should_equal 123.456 | ||
Decimal.parse "123.456.789,87654" locale=Locale.us . should_equal 123.456 |
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'm wondering if we should allow setting the custom format in parse
as well.
What if I have a string like 1.23.45.67.89,88
(that I got from somewhere) and want to parse it?
But that can be done in future iterations.
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.
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.
Looks good to me
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.