fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.math.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. BigDecimal value = BigDecimal.valueOf(3.11).multiply(BigDecimal.valueOf(3.11));
  11. value = value.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).divide(BigDecimal.valueOf(100));
  12. System.out.println(value.doubleValue());
  13. }
  14. }
Success #stdin #stdout 0.08s 53508KB
stdin
Standard input is empty
stdout
9.67