Is there a suggest way to negate a number? #489
-
| 
         Is multiplying by an amount of -1 the typical way to negate a number? This works, but I am curious if I missed something in the documentation. const d = multiply(dinero({ amount: 1000, currency: USD }), { amount: -1 }); | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            sarahdayan
          
      
      
        Nov 12, 2021 
      
    
    Replies: 1 comment 2 replies
-
| 
         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); | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
      Answer selected by
        sarahdayan
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
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: