I have to check if float number is negative or not. If negative assign it zero otherwise print it So what I did was:
The above code fails for float values less in range less than -0.9.
for example if number is -0.001, -0.0000006 then it fails . How to implement in C.
Rich (BB code):
float my_num;
/* do some calculation */
if( (int32_t)my_num < 0 )
{
my_num = 0.0f;
}
else
{
print_float_on_lcd(my_num);
}
for example if number is -0.001, -0.0000006 then it fails . How to implement in C.
Last edited by a moderator: