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 DecimalArithmetic language #71

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

machship-mm
Copy link
Contributor

This pull request will merge in the handling of DecimalArithmetic.

Decimal (base10 numbers) arithmetic is different to floating point (base2 numbers) arithmetic, and in use cases that involve money, it's imperative that the user is given the option to have any arithmetic calculations made using fixed-point decimal numbers rather than floating point.

DecimalArithmetic is added and used strictly as an optional use case (not added to the full() language set). It is not used unless one specifies its use.

Use can be specified by calling the DecimalArithmetic language directly and evaluation expressions against that language. DecimalArithmetic overrides the default handling for scanner.Int and scanner.Float to use parseDecimal and then all arithmetic is run against the decimal.Decimal from the widely used shopspring/decimal repository.

Tests and Benchmark Tests have been added.

This pull request fixes #70.

Includes addition of parsing and operations against decimal.Decimal.
Includes tests and benchmarks.

DecimalArithmetic is not included in `Full` as it overrides float.
@generikvault generikvault merged commit 9d17f67 into PaesslerAG:master Nov 2, 2021
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

Successfully merging this pull request may close these issues.

Handle decimal/money arithmetic
2 participants