fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.math.BigDecimal;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. BigDecimal a = BigDecimal.valueOf(5);
  16. BigDecimal b = BigDecimal.valueOf(3);
  17. BigDecimal result = a.divide(b);
  18.  
  19. //System.out.println( "a: " + a );
  20. //System.out.println( "b: " + b );
  21. //System.out.println( "result: " + result );
  22.  
  23. }
  24. }
Runtime error #stdin #stdout #stderr 0.05s 2184192KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
	at java.math.BigDecimal.divide(BigDecimal.java:1690)
	at Ideone.main(Main.java:17)