Using the Standard Mathematical Functions

Java provides standard mathematical functions through the static methods of the java.lang.Math and java.lang.StrictMath (new in SDK 1.3) classes. These methods support absolute value calculation, trigonometry, exponentiation, min/max determination, rounding, random number generation, and other utilities. The java.lang.Math implementation won't necessarily produce identical results on different platforms. These differences are in the least-significant bits and are unimportant for most applications. However, SDK 1.3 added java.lang.StrictMath. This implementation does not perform as well as java.lang.Math, but its methods are guaranteed to produce platform-independent results.

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.