PIXEL
DOCK

I like the smell of Swift in the morning…

How to compare two NSDecimalNumber values

Posted: | Author: | Filed under: iOS, Objective-C | Tags: , , | No Comments »

Recently I had to use NSDecimalNumber objects to avoid the rounding errors that come with float values. While comparing two float values is as easy as it gets comparing two NSDecimalNumbers works a bit different:

NSDecimalNumber is a subclass of NSNumber so you have to use NSNumber’s compare: method to compare the values:


Leave a Reply