Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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)".
- */
- //i.e. The following code will print "0.0 is true".
- if (0.0)
- {
- System.println("0.0 is true");
- }
- //Full test case:
- if (0 == 0.0)
- {
- System.println("0 == 0.0: PASSED....");
- }
- else
- {
- System.println("0 != 0.0: FAILED....");
- }
- if (0.0)
- {
- System.println("0.0 is truthy: FAILED....");
- }
- else
- {
- System.println("0.0 is falsey: PASSED....");
- }
- if (0)
- {
- System.println("0 is truthy: FAILED....");
- }
- else
- {
- System.println("0 is falsey: PASSED....");
- }
Add Comment
Please, Sign In to add comment