Hi, I'm new to this forum and i'm looking for a bit of help specifically with one line out of 3255.
this always returns 0.027 no matter what the value of E is there a way round this or have i done something wrong?Code:Rf = 0.027*(pow(E,(1/3)));
Hi, I'm new to this forum and i'm looking for a bit of help specifically with one line out of 3255.
this always returns 0.027 no matter what the value of E is there a way round this or have i done something wrong?Code:Rf = 0.027*(pow(E,(1/3)));
The problem is that 1/3 is interpreted as integer arithmetic by your compiler. 1/3 with integers is 0 and anything raised to the power of 0 is 1. So basically, your code says:
To tell the compiler you want floating points, use 1.0 and 3.0 or cast the values.Code:Rf = 0.027*1
I suspect it's 1/3 returning an integer value of zero. Try 1.0/3.0 .
EDIT - ...Looks like Kenki beat me to it.
Last edited by DougDbug; 05-18-2005 at 12:06 PM.
thanks