hi, i need advice on truncating a double to a double of 2 decimal places. my method is written as
strangely, the returned result has no decimals. i have tried DecimalFormat but it is returning a STRING instead of a double.
Code:
private static double trancate(double x)
{
long y=(long)x*100;
double z= (double)y/100;
return z;
}
strangely, the returned result has no decimals. i have tried DecimalFormat but it is returning a STRING instead of a double.