Class 1, Part 2 |
Intro to Java 30-IT-396 |
|
Mathematical Functions, Constants
-
Just as in JavaScript, we have a Math object that performs complex functions.
-
Math.sqrt(4); Returns the square root of the value provided. Would
return 2 in this case.
-
Math.pow(3, 2); Returns the first argument to the power of the second.
9 in this case.
-
And the trig functions:
-
Math.sin(), Math.cos(), Math.tan(), Math.atan(), Math.atan2()
-
Exponent and log:
-
And some constants:
-
Math.PI : a close approximation to pi (3.14159....)
-
Math.E : a close approximation to e.
Converting Numeric Types
-
Converting to a type with more memory room is easy. But, converting
to a type with less room often loses accuracy.
-
When performing a mathematical computation, both operands are converted
to a common, usually larger, type.
Casts
Created by: Brandan
Jones January 4, 2002