#What are the ways to convert decimals to integers in php?
Methods for converting decimals to integers:
The first method:
Use the ceil function, for small The further operation on the numerical value is to add one to the integer part no matter what it is after the decimal point.
The result of the operation: Both values are added relative to the integer part One
The second method:Use the floor function to convert the float type decimal into a float value without a decimal point
After running, it can be seen that the value after the decimal point is discarded
This method is to directly obtain the decimal The integer value part of the type, regardless of what is after the decimal point, The operation result is the same as the second method
The third Method: is the rounding method we often talk about. After the decimal point, 5 is rounded up, otherwise it is rounded off.
The result of the operation: 3.333 is rounded off to become 3, and 8.888 is rounded off. Became 9,
Recommended tutorial: "php tutorial"
The above is the detailed content of How many ways to convert decimal to integer in PHP?. For more information, please follow other related articles on the PHP Chinese website!