// compute exponent if number were written in scientific notatation int exponent = (int) (Math.floor( Math.log10( value ))) + 1; // e.g. 12345.0 -> 0.12345E06 -> exponent 6, mantissa 0.123454. // Regular (int) rounds toward 0.