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. int i = 1234567890;
  16. BigDecimal bd = new BigDecimal( i ) ;
  17. int backAgain = bd.intValueExact() ;
  18. int result = i - backAgain ;
  19. boolean isZero = ( result == 0 ) ;
  20.  
  21. System.out.println( "isZero: " + isZero ) ;
  22. System.out.println( "i: " + i ) ;
  23. System.out.println( "bd: " + bd ) ;
  24. System.out.println( "backAgain: " + backAgain ) ;
  25. System.out.println( "result: " + result ) ;
  26. System.out.println( "isZero: " + isZero ) ;
  27.  
  28. }
  29. }
Success #stdin #stdout 0.13s 54176KB
stdin
Standard input is empty
stdout
isZero: true
i: 1234567890
bd: 1234567890
backAgain: 1234567890
result: 0
isZero: true