proposal: math/big: Comparison to arbitrary number of decimal points #71288
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Milestone
Proposal Details
When representing arbitrary precision to compare two decimal money values, I have come to realize that sometimes the following code:
Can have the output
I would classify this as an unexpected result.
[For context, float1 is the sum of big floats parsed from strings, each string is formatted matching the regex "\d+.\d\d"]
At some point, during adding, the internal mantissas does not match, triggering comparison to view the values as not equal.
In this specific case, this code gets around the problem:
I propose an arbitrary precision comparison similar to the PHP arbitrary precision library, which allows comparison down to a specific number of digits.
I realize that base 10 are a human concept and not a machine one, and likely string manipulation will be required to compare the values.
Proposal:
The text was updated successfully, but these errors were encountered: