See, I want to write a function that takes a floating-point parameter and rounds the float to the nearest currency value (float with two decimal places), but if the float parameter has a zero fraction (that is, all zeros are behind the decimal place), then it returns float as an integer (or, i.e., truncates the decimal part, since all zeros are all the same.).
However, I found that I canβt understand how to determine if a fraction has a zero fraction. I do not know if there is a PHP function that already does this. I watched. The best I can think of is to convert a floating-point number to an integer by setting it first, and then subtract the integer part from the float, and then check if the difference is zero or not.
source share