Guest User

Untitled

a guest
Dec 5th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*In any other programming language, both 0 and 0.0 would be false and "0 == 0.0" would still probably be true. This means to implement a simple division function "x / y" it's not enough to test "if  y)", you have to test "if (y != null && y != 0)".
  2. */
  3. //i.e. The following code will print "0.0 is true".
  4. if (0.0)
  5. {
  6.   System.println("0.0 is true");
  7. }
  8.  
  9.  
  10. //Full test case:
  11.         if (0 == 0.0)
  12.         {
  13.             System.println("0 == 0.0: PASSED....");
  14.         }
  15.         else
  16.         {
  17.             System.println("0 != 0.0: FAILED....");
  18.         }
  19.         if (0.0)
  20.         {
  21.             System.println("0.0 is truthy: FAILED....");
  22.         }
  23.         else
  24.         {
  25.             System.println("0.0 is falsey: PASSED....");
  26.         }
  27.         if (0)
  28.         {
  29.             System.println("0 is truthy: FAILED....");
  30.         }
  31.         else
  32.         {
  33.             System.println("0 is falsey: PASSED....");
  34.         }
Add Comment
Please, Sign In to add comment