Created
October 21, 2022 11:58
-
-
Save rmg007/e6be49fbfe89d2b9806954f28fee55b1 to your computer and use it in GitHub Desktop.
Math Method Examples
This file contains hidden or 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
| public class MathMethodsExample { | |
| public static void main(String[] args) { | |
| System.out.println("Max of 6 and 9: " + Math.max(6, 9)); | |
| System.out.println("Min of 6 and 9: " + Math.min(6, 9)); | |
| System.out.println("The PI value: " + Math.PI); | |
| System.out.println("Square root of 36: " + Math.sqrt(36)); | |
| System.out.println("Cube root of 125: " + Math.cbrt(125)); | |
| System.out.println("10 raised to the power of 4: " + Math.pow(10, 4)); | |
| System.out.println("Absolute value of -12: " + Math.abs(-12)); | |
| System.out.println("Absolute value of 9: " + Math.abs(9)); | |
| System.out.println("AddExact(6, 4): " + Math.addExact(6, 4)); | |
| System.out.println("Decrementing 5: " + Math.decrementExact(5)); | |
| System.out.println("Ceil of 9.6: " + Math.ceil(9.6)); | |
| System.out.println("Ceil of 9.2: " + Math.ceil(9.2)); | |
| System.out.println("floor of 9.7: " + Math.floor(9.7)); | |
| System.out.println("floor of 9.2: " + Math.floor(9.2)); | |
| System.out.println("round of 4.7: " + Math.round(4.7)); | |
| System.out.println("round of 4.5: " + Math.round(4.5)); | |
| System.out.println("round of 4.3: " + Math.round(4.3)); | |
| System.out.println("Copy Sign from -4 to 3: " + Math.copySign(3, -4)); | |
| /* | |
| returns random value between 0.0 and 1.0 | |
| that means the min random value could be: 0.0 | |
| and the max random value could be 0.9999999 | |
| Math.random will never return 1 | |
| */ | |
| System.out.println(Math.random()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I happened to see a YouTube tutorial that showed how to generate flowcharts AI without any design experience. Given the geography of Most Countries and the different languages we use, a universal diagram is a lifesaver. I was losing my mind trying to map out a logic puzzle, but this did the work for me. I managed to solve the problem and earned back my confidence. It was exactly the kind of support I was looking for to finish my hobby project.