Skip to content

Is there a suggest way to negate a number? #489

Answered by sarahdayan
johnhooks asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @johnhooks, multiplying by -1 is indeed the recommended way to negate a Dinero object.

However, you don't have to use a scaled amount for this since -1 is an integer:

const d = multiply(dinero({ amount: 1000, currency: USD }), 1);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@johnhooks
Comment options

@sarahdayan
Comment options

Answer selected by sarahdayan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants