Click to See Complete Forum and Search --> : C error with an integer?
TomMacs
09-19-2004, 10:48 PM
All right here's an odd error that I can't seem to figure out. I'm using KDevelop 3. Here's the compilers error report:
4.09999999999999975575093458246556110680103302002e-1' cannot be used as a function
and here's the code thats giving the problem:
// Inductance of secondary coil
float SIuH;
SIuH = pow(STT * (SD / 2), 2) / 9*(SD / 2) + 10 * SH;
cout << "Inductance of Secondary Coil (mH): " << SIuH << endl;
hmmm, I'm stuck.
bryan.6
09-20-2004, 01:52 AM
could it be something dealing with the pow... does that return a double? i wouldn't think that would screw up anything though...
do you get this exact error ( about 5 ) EVERY time you run the program, or does the number in the error change with the inputs?
TomMacs
09-20-2004, 11:52 AM
I haven't thought about changing the format of the equation, but what I have done was experiment with different number values. They all came in with the same result and error message. I tired long double and double. When I get home though I plan on proceeding with what you said, I'll play around with the format of the equation and pow(). I do know that this one specific equation does result in a very large decmial point.
cybertron
09-20-2004, 01:19 PM
Incidentally, in my experience pow is very slow if you're just squaring something. In a program I wrote once I got at least a 200% speed increase by just changing my squaring from using pow to simply multiplying the thing by itself. That would also eliminate pow as a source of the problem.
bwkaz
09-20-2004, 08:14 PM
What are STT, SD, and SH? Are they #defined to something, or are they all variables? If they are #defined, what are they #defined to? Does it help to make them "const double"s or "const long double"s?
madcompnerd
09-20-2004, 09:00 PM
You can also always just rewrite POW, for ints it's like a 4 line function.
I dunno how you compiled it as c code, I dunno how to use iostream from c, but I compiled it as c++ code and it worked.