Thanks, the full code is actually a rounding function and this is it:
Code:
double roundd(nm_valor)
double nm_valor;
{
double di_exponente= (double)0.00;
double aux=0.00;
unsigned long aux1 = 0; /* unsigned long aux1 = 0; */
int signo = 1;
if (nm_valor < 0.00)
{
signo = -1;
nm_valor = -nm_valor;
}
/* di_exponente = pow (10, (double) NM_DECIMALES);*/
di_exponente = pow ((double)10, (double) NM_DECIMALES);
aux = ((nm_valor * di_exponente) + 0.5);
aux1 = aux/1;
aux = aux1 / di_exponente;
aux = aux * signo;
return(aux);
}
And if the value that went in was x.5 the rounded value sometimes was x and sometimes x+1.
Seems part of the problem is with the prints which also do their own rounding...