Java - Math Notes
// Common math operations + - * / %
int a = 1234;
int b = 7;
int answer = a/b;
int remainder = a%b;
System.out.println(answer +" with a remainder of " + remainder);
// NOTE: PEMDAS
// Increment and de-increment operators
double c = 0;
c = c+1;
c++;
System.out.println(c);
// Shortcut operators += -=
c += 10;
System.out.println(c);
// When you divide to integers you will get an integer result
// Methods of the math class
// abs pow sqrt ceil floor round min max PI random
// log sin cos tan asin acos atan toDegrees toRadians
// NOTE: sin cos tan gives answers in radians
System.out.println( Math.abs(-10) );
System.out.println( Math.pow(12,3) );
System.out.println( Math.sqrt(99) );
System.out.println( Math.ceil(123.00001) );
System.out.println( Math.floor(123.9999) );
System.out.println( Math.PI );
Videos |
|
|
|
|
|