I have an NSDecimal in a tight calculations loop, where I need to floor the value. I want to prevent creating fat NSDecimalNumber objects just for that. Is there a cost-efficient way to get a floor? That floor is just needed to calculate how many times another value might fit in there, with no rest. The NSDecimal API doesn't provide something like floor…
Iphone – Lightweight way of flooring an NSDecimal
cocoa-touchiphoneuikit
Related Topic
- Ios – How to add CGPoint objects to an NSArray the easy way
- Objective-c – way to remove the separator line from a UITableView
- R – Memory Management with NSDecimalNumber: How to avoid memory problems in tight loops
- Iphone – How to encode an NSDecimal
- Iphone – execute the NSDecimalCompact() function on every NSDecimal I create
- Iphone – How would an NSScanner expect a string for scanning an NSDecimal
Best Answer
You can use the
NSDecimalRound()
function with theNSRoundDown
rounding mode:For more info take a look at the docs here.