I've come across some blogs and forum posts where people say one should use NSDecimalNumber instead of floats when dealing with currency. I find I have to convert from NSDecimalNumber to Floats/Doubles in order to do some arithmetic which in my mind negates the usefulness of NSDecimalNumber. I mean why not just use floats and not bother with all the conversions hassles?
What's the benefit of NSDecimalNumber and how do you perform arithmetic on it?
What is this error thing that floats have and NSDecimalNumber does not which is why people 开发者_如何学编程say one MUST use NSDecimalNumber when dealing with currencies? Please quantify the error?
Thanks in advance,
Hiren.The class documentation has arithmetic instructions. The class is immutable so it looks a little funny. This question has very good answers and the link in the accepted answer is key.
精彩评论