I need to format a floating point number in PHP so it can be inserted into a column in a table which is of type decimal(6,5).
So,
20 would get formatter to 20.00000
20.5 would get formatted to 20.50000
How to do it in PHP?
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.
To avoid the float inherent precision error,
cast first to decimal(9,2), then to decimal(6,5).