Reputation: 70
For some odd reason, I receive an NSDecimalNumberOverflowException from the following:
NSDecimalNumber *a = [NSDecimalNumber notANumber];
NSDecimalNumber *b = [NSDecimalNumber notANumber];
NSLog(@"%@",[a decimalNumberByAdding:b]);
This seems unexpected to me since the documentation for NSDecimalNumber's notANumber states that any arithmetic operation receiving a NaN as an argument returns a NaN...
I receive the same error for 1+NaN and NaN+1...thankfully 1+1 still gives 2.
Any ideas on what's going on?
Upvotes: 1
Views: 737
Reputation:
Per posters request:
Could it be that it is creating a signaling NaN vs. a quiet NaN? These concepts exist in IEEE-754, not sure about NSDecimalNumber. What happens if you do [x decimalNumberByAdding: x]
where x is the NSDecimalNumber created byte 1.0/0?
Upvotes: 1
Reputation: 16861
Why do you want to try to perform arithmetic on a NaN value? NaN is an error value.
Upvotes: 1