This article provides two methods, one that converts decimals into strings, and then uses "." To intercept, to go. The substring length after. There is also a decimal *10, such as the N-square, for example, 10 of the 8-square to the remainder of 8, and then continue to the 10, until the result of the remainder of 10 is not 0.
In comparison, the first method is much better, the reason is that, for example, 1.000004 at the very edge of the time or 0.99999 such a sub-PHP processing will be problematic, there will be errors, resulting in a different number of digits. And the accuracy is difficult to grasp, so dealing with this boundary-related problems can finally be done with a string or string.
First Kind
Private Function _getfloatlength ($num) {$count = 0; $temp = explode ('. ', $num); if (sizeof ($temp) > 1) {$decimal = End ($temp); $count = strlen ($decimal);} return $count;}
The second Kind
function Getfloatlength ($a) {if (($a-(int) $a) <1e-9) {$count = 0;} $a =fmod (1e9* $a, 1E9), while ($a%10==0) {if ($a ==0) break; $a = $a/10; $count--;} return count;}