Search Techno Talk

The Math Library Class (in Java)

Posted 9:49 PM by Sobia in Labels: , ,
Class Math groups together a typical and quite conservative collection of mathematical functions. The functions provided can be classified as follows:
  • Absolute value, ceiling, floor, min and max functions. These are suitably overloaded so that you can pass in any numeric type without having your arguments automatically cast to different types, thereby possibly losing accuracy.

  • Square root, power, logarithm, and exponential functions. All of these take and return double values only (double, not float, is the default floating point accuracy used by java). You do not need to use casts when passing other numeric types, like int or float, because Java's compiler will automatically convert (compatible) argument types for you. A constant for the natural logarithm base is defined as a double precision value in the constant Math. E.

  • Trigonometric functions (sin, cos, tan, asin, acos, atan). All of these functions work with angles expressed in radians instead of degrees. A full circle in radians is 2*PI radians (as opposed to 360 degrees). Pi is conveniently defined to double precision as the Math class constant Math. PI.

  • A pseudo-random number generator function. One method, random (), is provided as a basis for randomness in applications. Random numbers are very important in simulations, statistical analysis, and, of course, games.


0 comment(s) to... “The Math Library Class (in Java)”

0 comments:

Post a Comment

Google Groups
Subscribe to Techno Talk
Email:
Visit this group