Skip to content
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 NumberFormatter #1793

Merged
merged 1 commit into from
Sep 6, 2018
Merged

Add NumberFormatter #1793

merged 1 commit into from
Sep 6, 2018

Conversation

jodastephen
Copy link
Member

Thread-safe wrapper around DecimalFormat/NumberFormat.
ThreadLocal is 2.5x faster than clone() for common cases.

Thread-safe wrapper around DecimalFormat/NumberFormat
ThreadLocal is 2.5x faster than clone() for common cases
* The integer part will be grouped if the flag is set.
* The decimal part will never be grouped or truncated.
* The implementation uses English locale data, which uses commas as a separator and a decimal point (dot).
* Numbers will be rounded using {@link RoundingMode#HALF_EVEN}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why HALF_EVEN and not HALF_UP? HALF_UP is the "standard" rounding mode everyone learns at school. From the Javadocs for HALF_UP

Note that this is the rounding mode commonly taught at school.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is what DecimalFormat uses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it does. That surprises me.

@cjkent cjkent merged commit b3a799c into master Sep 6, 2018
@cjkent cjkent deleted the topic/number-formatter branch September 6, 2018 15:08
@jodastephen jodastephen added this to the v2.1 milestone Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants