Hello again,
I was testing to truncate a value with how many decimals case i want.
Nice, i found a function that make this, but, use double, and i need to use float,
double is crashing everything with StackOverFlow errors that i can't fix.
And with float that works..
This is the code of the function.
double trunc(double value, int decimal_places){
double integer = 0,fractional = 0,output = 0;
int j = 0,places = 1;
fractional = modf(value, &output);
for( int i = 0; i < decimal_places + 1; i++ ){
fractional = modf(fractional, &integer);
for( j = 0; j < i; j++ ){
places *= 10;
}
output += integer / places;
places = 1;
fractional *= 10;
}
return output;
}
Thanks