Guest User

Untitled

a guest
Jul 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /**
  2. * An example to show that while floats can represent
  3. * decimal numbers and large numbers, floats only
  4. * have 6-7 digits of precision.
  5. *
  6. * Friday, January 14
  7. */
  8. package example03;
  9.  
  10. /**
  11. * @author pajensen
  12. *
  13. */
  14. public class NumberExperiment
  15. {
  16.  
  17. /**
  18. * @param args
  19. */
  20. public static void main (String[] args)
  21. {
  22. int x = 0;
  23. float y = 0; // Try changing this to 'double' instead of float
  24.  
  25. while (x == y)
  26. {
  27. x = x + 1;
  28. y = y + 1;
  29. }
  30.  
  31. System.out.println ("X = " + x);
  32. System.out.println ("Y = " + y);
  33. }
  34.  
  35. }
Add Comment
Please, Sign In to add comment