We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I do not see the right answer when i use this function.
float comppoly(x) { float y1,y2; float a1=0.1,b1=0.3,a2=2.1,b2=5.3,c=0.22; y1=a1*x+b1; y2=a1*x^2+b2*x+c; return(y2>y1);};
?can you say what is wrong?
It wouldn't hurt giving the input parameter x a data type too.
LOL, didn't see that (just looked at the code) :-)
My ChrystalBall assumes:
float comppoly(float x) { float y1, y2; float a1=0.1, b1=0.3, a2=2.1, b2=5.3, c=0.22; y1 = (a1 * x) + b1; y2 = (a1 * x^2) + (b2 * x) + c; return(y2 > y1); }
So, I guess that the compiler warns, and assumes int. That of course gives the wrong answer if fed with float ...
. BR, /th.
Hah. Now it won't even compile (on a sane compiler). Not exactly a big improvement, is it?
:->
x^2 is a bit problematic when x is a float.
But then again - it is a bit problematic when x is an int too...