Are there equivalent methods for ceilf and floorf for the NSDecimalNumber type? I couldn’t seem to find any.
Are there equivalent methods for ceilf and floorf for the NSDecimalNumber type? I couldn’t
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple solution: You can get the float value of the number object and call
ceilf()orfloorf():Otherwise, you can use the
– decimalNumberByRoundingAccordingToBehavior:method.First you’ll need to implement the
NSDecimalNumberBehaviorsprotocol for each rounding mode you want to use:And then (assuming your decimal number is 12.5):
You’ll get: