Obviously java.lang.StrictMath contains additional functions (hyperbolics etc.) which java.lang.Math doesn’t, but is there a difference in the functions which are found in both libraries?
Obviously java.lang.StrictMath contains additional functions (hyperbolics etc.) which java.lang.Math doesn’t, but is there a
Share
The Javadoc for the
Mathclass provides some information on the differences between the two classes:Therefore, the
Mathclass lays out some rules about what certain operations should do, but they do not demand that the exact same results be returned in all implementations of the libraries.This allows for specific implementations of the libraries to return similiar, but not the exact same result if, for example, the
Math.cosclass is called. This would allow for platform-specific implementations (such as using x86 floating point and, say, SPARC floating point) which may return different results.(Refer to the Software Implementations section of the Sine article in Wikipedia for some examples of platform-specific implementations.)
However, with
StrictMath, the results returned by different implementations must return the same result. This would be desirable for instances where the reproducibility of results on different platforms are required.