It will have an effect - it casts to float, while the compiler would cast to double. So you potentially lose precision.
It will have an effect - it casts to float, while the compiler would cast to double. So you potentially lose precision.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
well, the function is O:K, the error appears before the function works
The problem has nothing to do with type conversions (aka castings).
In iterar(), x becomes a large negative number, eventually approaching the negative value with greatest magnitude that can be stored in a floating point variable. With very large (as in distance from zero) values, the computation of tan(x) triggers a floating point overflow (simply because the computation will typically be approximated by some Taylor series or similar approximation, which means a power of x is computed).
You will need to adapt your algorithm to avoid situations of very large values being iteratively computed.
>> well, the function is O:K, the error appears before the function works
How do you know? Have you narrowed down the problem and made the code smaller? Keep removing unnecessary code until you make a tiny program that still has the error.
You are right,
i ook this part of program and execute it and works! That is the error is not about casting..
thii is the program
Code:#include<stdio> #include<stdlib> #include<iostream> #include<math> #include<conio> #define PI 3.14159265358979324 using namespace std; int main() { float c; int i; for (i=0;i<10;i++) { c= (float) (2*i +1)* PI/2.0 - PI/180.0 ; printf("%7.4f \n",c); } getch(); }
i mean I took
I dont know how to solve this problem, the problem remains!!!!
Did you see the posts by others in this thread indicating where they think the error might be, like grumpy's post? What have you done to look at those? Can you narrow down the problem by calling printf before calling tan(x) to see what x is as suggested earlier?
i am tryng.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Thank you all(Daved,et al.)
I solved the problems,
The problem was with the function.
Gracias!!!!
Glad you got it working mcaro!