Created
February 1, 2020 17:17
-
-
Save ionelh/b969590239b6649c07dc1604d4da4d21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// integers default to integers | |
System.out.println(42 + 2); | |
System.out.println(42 - 2); | |
System.out.println(42 * 2); | |
System.out.println(42 / 4); | |
System.out.println(42 % 4); | |
// doubles default to doubles | |
System.out.println(42.0 / 4.0); | |
// Numerous math functions (check the doc for complete list) | |
System.out.println(Math.abs(-1)); | |
System.out.println(Math.ceil(4.25)); | |
System.out.println(Math.floor(4.25)); | |
System.out.println(Math.round(4.25)); | |
System.out.println(Math.max(4,5)); | |
System.out.println(Math.min(4,5)); | |
System.out.println(Math.log(1)); | |
System.out.println(Math.log10(1)); | |
System.out.println(Math.pow(2,2)); | |
System.out.println(Math.sqrt(4)); | |
System.out.println(Math.random()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment