|
-
December 29th, 2010, 11:43 PM
#1
Order of multiplication matters?
I've been fooling around with C++ over the Winter break to grow my knowledge when I came across this....
Say I have a function that takes a scientific constant, a coefficient and a variable like pV=nRT using the universal gas constant or using PI for some trig function.
If I define pi using #define, get the radius as a param and the coeff is hard coded, I have to perform the math like so: diameter = 2(coeff) * radius(passed param) * pi(literal);
If I switch the order, I get an invalid type argument for unary * exception.
What exactly is going on here that causes this type of behavior?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|