I am looking for a way to turn a NSDecimalNumber
negative by multiplying by -1
.
/* decNumber is the one I would like to turn negative */
NSDecimalNumber *decNumber = [values objectAtIndex:billIndex];
NSDecimalNumber *minusOne = [[NSDecimalNumber alloc] initWithInt: -1];
finalValue = [[NSDecimalNumber alloc] initWithDecimal: [[decNumber decimalNumberByMultiplyingBy: minusOne] decimalValue]];
This works but it feels like it's just too much for such a simple logic. Can you think of a better way to achieve this?
[NSDecimalNumber decimalNumberWithString:@"-1"]
? – Benzvi