how to check overflow of float number

Status
Not open for further replies.

userx51

Junior Member level 2
Joined
Apr 21, 2013
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,432
in C code, Microcontroller, how to find out if a x overflown?.
float x,y;
x=*someval+z;
:-?
 

You can not find a variable was over flown but you can avoid it, if that was your series problem then do like this

Code C - [expand]

1
2
3
4
5
6
double temp;

if(temp = ((y)*someval+z) > MAX_FLOAT_VALUE)
of = 1;
else
x=(y)*someval+z;



better if you have doubt that its going to ovrflow then you shd use a double type....
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…