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 stripTrailingZeros() method #311

Open
morale3232 opened this issue Jul 25, 2024 · 0 comments
Open

Add stripTrailingZeros() method #311

morale3232 opened this issue Jul 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@morale3232
Copy link

Is your feature request related to a problem? Please describe.
The java.math.BigDecimal class has a stripTrailingZeros() method that would be nice to have in this implementation.

Describe the solution you'd like
I'd love to see the same method implemented in the same fashion.

Describe alternatives you've considered
I've written a small helper function that takes the string representation of the BigDecimal and manually removes all trailing zeros, but I would prefer to have the official method.

Additional context


    public BigDecimal stripTrailingZeros() {
        if (this.intCompact != 0L && (this.intVal == null || this.intVal.signum() != 0)) {
            return this.intCompact != Long.MIN_VALUE ? createAndStripZerosToMatchScale(this.intCompact, this.scale, Long.MIN_VALUE) : createAndStripZerosToMatchScale(this.intVal, this.scale, Long.MIN_VALUE);
        } else {
            return ZERO;
        }
    }
@ionspin ionspin added the enhancement New feature or request label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants