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

Conversation

Projects
None yet
2 participants
@jodastephen
Member

jodastephen commented Sep 5, 2018

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

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

@jodastephen jodastephen requested a review from cjkent Sep 5, 2018

* 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}

This comment has been minimized.

@cjkent

cjkent Sep 6, 2018

Member

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.

This comment has been minimized.

@jodastephen

jodastephen Sep 6, 2018

Member

It is what DecimalFormat uses.

This comment has been minimized.

@cjkent

cjkent Sep 6, 2018

Member

So it does. That surprises me.

@cjkent

cjkent approved these changes Sep 6, 2018

@cjkent cjkent merged commit b3a799c into master Sep 6, 2018

15 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
security/snyk - modules/basics/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/calc/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/collect/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/data/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/loader/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/market/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/math/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/measure/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/pricer/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/product/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/report/pom.xml (OpenGamma) No new issues
Details
security/snyk - pom.xml (OpenGamma) No new issues
Details

@cjkent cjkent deleted the topic/number-formatter branch Sep 6, 2018

@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