Number class
In the actual development process, we often encounter situations where we need to use objects instead of built-in data types. To solve this problem, the Java language provides a corresponding wrapper class for each built-in data type.
All packaging classes (Integer, Long, Byte, Double, Float, Short) are subclasses of the abstract class Number.
Math class
Math contains properties and methods for performing basic mathematical operations, such as elementary exponents, logarithms, square roots, and trigonometric functions.
Math methods are defined as static form, may Math class by the main function in a direct call .
Comparison of Math's floor, round and ceil method examples
- floor(): returns the largest integer less than or equal to (<=) the given parameter
- round(): It means rounding, the algorithm is Math.floor(x+0.5), which means adding 0.5 to the original number and then rounding down.
- ceil(): returns the smallest integer greater than or equal to (>=) the given parameter, the type is double-precision floating point