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

calling DivRound on a negative number returns a positive number #385

Open
fawkesley opened this issue Sep 25, 2024 · 0 comments
Open

calling DivRound on a negative number returns a positive number #385

fawkesley opened this issue Sep 25, 2024 · 0 comments

Comments

@fawkesley
Copy link

Thanks for this library - happy user for years.

Discovered something today unexpected:

a := decimal.NewFromFloat(-35.0)
fmt.Println(a.DivRound(decimal.NewFromFloat(5.0))

7

This is different from Go's default behaviour:

fmt.Println(-35.0 / 5)

-7.0

Am I missing something? This seems fundamentally incorrect behaviour.

Is there a way divide and preserve sign?

Cheers
Paul

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

1 participant