Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. import java.math.BigDecimal;
  3.  
  4. public class TestNumbers {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. BigDecimal a1 = new BigDecimal(0.3);
  9.  
  10. BigDecimal a11 = new BigDecimal("" + 0.3);
  11.  
  12. double a2 = 0.3;
  13.  
  14. float a3 = 0.3f;
  15.  
  16. double b1 = 293.37;
  17.  
  18. int a = (int) (a2 * 100);
  19.  
  20. int b = (int) (b1 * 100);
  21.  
  22. double c = a2 + a2 + a2;
  23.  
  24. float f = (float) (c);
  25.  
  26. float f2 = a3 + a3 + a3;
  27.  
  28. BigDecimal d = a1.add(a1).add(a1);
  29.  
  30. BigDecimal d2 = a11.add(a11).add(a11);
  31.  
  32. double e = c / 100.0;
  33.  
  34. System.out.println("a = " + a);
  35.  
  36. System.out.println("b = " + b);
  37.  
  38. System.out.println("c = " + c);
  39.  
  40. System.out.println("f = " + f);
  41.  
  42. System.out.println("f2 = " + f2);
  43.  
  44. System.out.println("d = " + d);
  45.  
  46. System.out.println("d2 = " + d2);
  47.  
  48. System.out.println("e = " + e);
  49.  
  50. System.out.println((0.3f + 0.3f + 0.3f));
  51.  
  52. }
  53.  
  54. }
Add Comment
Please, Sign In to add comment