Problem with ^ operator and some rounding
Hello, I am trying to calculate a number that is:
rChange = 1/(1+10^(deltaR/400));
I''m currently testing it with deltaR being equal to 0, so the equation should come out with rChange = .5
However, my program comes up with the whole thing being 0.
Also, I tried to change the equation so it would accept float numbers, for example, instead of the 400 I used 400.0f and deltaR went in as a float instead of an integer. But my compiler said that ^ could only use integers.
Can anyone solve this one for me? Thanks.
Are you aware that in C, C++, and Java, ^ is the modulus operator, not the exponentiation operator? The latter does not exist in C or C++, and is replaced by the function pow().
"Sneftel is correct, if rather vulgar." --Flarelocke
"Sneftel is correct, if rather vulgar." --Flarelocke
Oh thanks lol boy do I feel stupid now. Yeah, I was testing it with all kinds of numbers and it was coming up with weird things and I was thoroughly confused.
[edited by - EvilProgrammer on April 20, 2004 9:07:12 PM]
[edited by - EvilProgrammer on April 20, 2004 9:07:12 PM]
heh, oops. Yeah. Man, I dunno what the heck I was thinking.
"Sneftel is correct, if rather vulgar." --Flarelocke
[edited by - sneftel on April 20, 2004 9:20:07 PM]
"Sneftel is correct, if rather vulgar." --Flarelocke
[edited by - sneftel on April 20, 2004 9:20:07 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement