i wanted to Round off Float value,but the correct computed value is not returning to calling Function .
i have following functions .
init -- which calls 'compare' function.
compare - which will call rounding function .
My issue was when i call "compare" function the return value from "Round_Float" function is not visible in "compare" function .
here is code ..
Code:
float Util_Round_Float(float data, unsigned int aft_dec_digits )
{
float sign = 1.0;
unsigned int index = 0;
unsigned int local_var = 1;
unsigned int temp_var = 0;
float output = 0.0;
float X = 0;
..................
..................
X = sign * output;
return( X );
}
float Util_Float_Abs( float data )
{
float ret_value = 0.0;
if( data > 0.0 )
{
ret_value = data;
}
else
{
ret_value = ( data * ( -1 ));
}
return( ret_value );
}
void init ()
{
float value = 12.5;
compare (value);
}
void Compare( float Ratetype )
{
Ratetype = (float )Util_Round_Float( Ratetype, 5 );
}
when i debug "RoundFloat" function i am getting correct valuve.but the value returns to "compare" function it is not correct.
is it becoz the return valve of "Util_Round_Float" is a local ??