double truncate (double D,int n)

{

long multiplied;

double to_return;

multiplied = (D*pow(10,n)); // save only the first n digits after the decimal point . (as a long integer).

to_return = (multiplied / (pow(10,n)); // return to the trtunced (original ) number.

return (to_return);

}

for example:

in truncate (0.123456789,5) you'll get:

multiplied = 12345

to_return = 0.12345