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

No way to determine the scale/precision #78

Open
bjchambers opened this issue Jun 24, 2021 · 2 comments
Open

No way to determine the scale/precision #78

bjchambers opened this issue Jun 24, 2021 · 2 comments

Comments

@bjchambers
Copy link

I'd like to be able to distinguish a number such as 1 from 1.0. Specifically, the latter has more precision. I think this information could be retrieved from the scale/precision information in the BigDecimal, but there isn't an accessor for the scale. Is there a reason not to add one?

@akubera
Copy link
Owner

akubera commented Jun 26, 2021

No I don't see why it wasn't included. Both scale() and precision() are implemented in the BigDecimal standards of Java & Scala, only precision() is present in Go, Ruby, and GMP, so I pause and wonder if scale is an implementation detail, but I suppose it could always be calculated.

@dchenbecker
Copy link

In terms of utility, sometimes it's important to know that even if two values are equal, that one has more precision due to extra significant figures. precision() should be equivalent to digits() based on the docs of both Java and this crate. scale is available via the as_bigint_and_exponent() method, as the exponent, so we should be able to expose it as a scale method as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants