[A89] Re: Exponents
[Prev][Next][Index][Thread]
[A89] Re: Exponents
Might I suggest reading the help file?
If you'll check the library file, math.h, you'll find that it has a
perfectly functional pow() function already included. When writing
programs that involve any complicated math (anything besides +, -, *, /,
%), math.h is your friend.
for example:
pow(5, 6);
will present a warning (loss of precision casting ints as floats) but the
answer will be correctly 15625.0000000000f (or however precise it'd be as a
float)
Just make certain that you'll never be taking an even root of a negative
number. Most systems flag this as an error. TIGCC apparently does not and
returns garbage.
math.h is your friend.
At 08:21 PM 6/16/02 -0400, you wrote:
>Hey all,
>
>Anyone know how to do exponents in C, such as 5 to the 6th power and such?
>I looked in help, but all the funcitons I found having to do with exponents
>didn't seem to be just plain exponents. Am I just missing something or is
>that not possible in C?
>
>Brett
Follow-Ups:
References: