Archived

This topic is now archived and is closed to further replies.

EvilProgrammer

Problem with ^ operator and some rounding

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites