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

[Bug]: Multiplied negative values increases amount #713

Closed
2 tasks done
milankyncl opened this issue Jan 18, 2023 · 3 comments · Fixed by #711
Closed
2 tasks done

[Bug]: Multiplied negative values increases amount #713

milankyncl opened this issue Jan 18, 2023 · 3 comments · Fixed by #711
Assignees
Labels
bug Something isn't working

Comments

@milankyncl
Copy link

milankyncl commented Jan 18, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

After multiplying negative numbers it adds an extra amount into the Dinero object.

const d = dinero({ amount: -200, currency: USD });    // { amount: 200 }  -> OK!
const m = multiply(d, 1);                             // { amount: -201 } -> not OK!

Happy to share further details.

Reproducible in the attached Code Sandbox.

Expected behavior

To be the same, but just in a negative value.

Steps to reproduce

https://codesandbox.io/s/fervent-violet-qkozxe?file=/main.js

Version

2.0.0-alpha.13

Environment

Node.js v14.18.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@milankyncl milankyncl added the bug Something isn't working label Jan 18, 2023
@johnhooks
Copy link
Contributor

@milankyncl I think I why this bug might be happening. The core function transformScale preforms a rounding operation in multiply. The logic was recently reworked in down. I'll add some tests and dive into it soon.

@johnhooks
Copy link
Contributor

johnhooks commented Jan 21, 2023

@milankyncl Looks like this issue has already been fixed in PR #711, hopefully we can get it merged soon.

@kdurek
Copy link

kdurek commented Feb 8, 2023

Hey, sadly same happens multiplying positive dinero by -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants