-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
RFC: add getPrecision
method.
#58
Comments
Hi, what would be the difference between |
hi @BenMorel The PostgreSQL manual will say it better than me:
|
@BenMorel any interest? thanks! |
Working with precision is generally better than working with scale Check this example:(0.03/360)*8*30 = 0.02 Woking with scale of 10: ❌ 0.0199999920 == 0.02 Working with precision of 10: ✔0.02==0.02 |
@alexviar i'm not sure what your example shows but it's not precision of 10
|
It has a scale of 14 but a precision of 10. The precision refers to how many significant digits it has, not how many decimal places it has. https://www.logicbig.com/quick-info/programming/precision-and-scale.html For example Big.js uses scale whereas Decimal.js uses precision |
I did put in parentheses digits that was rounded, and underlined digits are the Periodo of decimal |
ah right thanks, i forgot that leading zeros are not significant. anyway, the point of this of was to simple add a |
Hi @bendavies, sorry for the late reply. I'm not against adding a @alexviar I'm not sure what the decimal period has to do with the precision? Anyway, you make me think that this would be a great addition to |
I opened issue #74 to track the BigRational as decimal number with period separately. |
I think I didn't explain myself well. I did put rounded decimals (and decimal period) in parentheses for illustrative purposes only. Precision is given by working with n significant digits instead of n decimal place:
Now, if we take the rounded values to do subsequent operations, we have:
Currently it can be circunvent by using |
Hi,
Similar to
getScale
, would you be on favor of adding a methodgetPrecision
?I want to perform app side validation on BigDecimal before passing to Postgres numeric fields, and
getPrecision
would make that easier.Thanks!
The text was updated successfully, but these errors were encountered: