Wednesday, August 14, 2013

JAVA FAQ's

1. Rounding of a double value to 2 digits.

-- Double TempTentSec = 0.0;
    TempTentSec = 111.0;
    TempTentSec = Math.round(TempTentSec * 100.0) / 100.0;

(Similarly to round of at 0 places:- Multiply & divide by 1.0)

2. Removing decimals without rounding off the double value.

-- TempTentSec = (double)Math.floor(TempTentSec);