Re: Math question
Re: Math question
- Subject: Re: Math question
- From: "John C. Randolph" <email@hidden>
- Date: Sat, 1 Sep 2001 16:27:28 -0700
On Saturday, September 1, 2001, at 02:34 PM, email@hidden wrote:
Hello all. i have a question about math in Cocoa. how do i do higher
level math? obviously i can do the basics */+-% without problem. but
what about doing things like raising a number to a power?
fooSquared = foo^2;
For other math functions in the C standard library, open a terminal
window and type "man math".
i've looked over the foundation functions like NSDecimalPower. i
understand everything about how to use them except how to generate the
NSDecimal i need. NSDecimal isn't a class, it's structure. how to i set
it to a number? i thought about using NSDecimalNumber (a class) and
using its function to return an NSDecimal for use in the NSDecimalPower
function, but still i can't figure out how to set it up first. there
must be something really easy i'm overlooking. thanks for your help in
advance.
NSDecimalNumber is for use when you need arbitrary precision and very
fine control of things like rounding behaviour.
-jcr
"This is not a book to be tossed aside lightly. Rather, it should be
hurled with great force." -Dorothy Parker