Is there a native PHP function which tells me how many decimal places a number has, or will I have to make my own?
IE:
0.8 -> 1
0.2345 -> 4
0.894 -> 3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll have to make your own if you really want that function. It shouldn’t be all that hard, though – just convert to a string,
explode()on the., and then take the length of the second element in the array.Beware of floating point inaccuracy, though.