-
operators operands
I've been looking for hours all over the net for just a simple list of the arithmetic operators, that can be used in C, and the syntax of operators and operands, but I can't find one. Can anybody tell me where one is?
I simply want to raise one floating point variable to a floating point power.
Also, I noticed that if i simply try to assign to a float variable, one integer divided by another, the compiler rounds the variable's value off to an integer, but displays a bunch of zeros after a decimal point. If I divide one float variable by another, I get a (thing on the left i forgot what its called) and a mantissa. Is the program "type-casting" the variable, changing its type? I'm confused. If it was, it wouldn't display the dec point and zeros, it would seem to me.
-
#include <math.h>
.
.
.
float a = 4.55;
float b = 3.58;
float c = pow (a, b); // a to power of b.
-
Thanks SamGwilliam -- I was able to get my computer to exponentiate, using the information you provided in your example. I did, however, as I had before, have to say something like...
float a;
a = 4.55;
to it, rather than telling it...
float a = 4.55;
-- because this sort of declaration caused it to respond with "Error blah blah blah."
Perhaps this is correct syntax in another compiler, but Borland Turbo C 2.01 (circa 1989) didn't like it.
-
I'm still looking for a simple list of the arithmetic operators, that can be used in C, and the syntax of operators and operands. I having trouble deducing these from the math.h file.
-
Try this, itīs an ANSII-C-reference.
klausi
-
> I've been looking for hours all over the net for just a simple list of the arithmetic operators
The only floating point operators which C supports "out of the box" are +,-,*,/
Everything else (log, exponents etc) can all be found as functions in math.h
> Perhaps this is correct syntax in another compiler, but Borland Turbo C 2.01 (circa 1989) didn't like it.
Shouldn't be a problem - though your very OLD (and pre-ANSI) compiler should really be replaced with something more up to date
Many excellent free compilers can be found here
www.compilers.net
-
Thanks klausi. Looks like one of the better references on the web (I finally managed to find a few).
Thanks Salem. I'm thinking about buying Borland Turbo C/C++ Suite. It includes a C tutorial, not just a tutorial on using their ide.
Since I'm just learning fundamentals, I don't need a comprehensive set of features yet. Though I like a good ide to save time.
I downloaded djgpp already. It looks very complete. But it also has a very complex installation procedure. I have't installed it yet.