You can try floatval , but floats are potentially lost.
You can try running the sprintf number to get it in a more correct format. The format string %.2f will result in a floating-point number with two decimal places. Excess places are rounded.
I'm not sure that sprintf will convert the value to a float inside for formatting, so a loss problem may still exist. In this case, if you are worried about two decimal places, you do not need to worry about the accuracy of losses.
source share