Default Number of Decimal Places to Output in PHP

前端 未结 6 1372
执念已碎
执念已碎 2020-12-18 13:37

I do my php work on my dev box at home, where I\'ve got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated t

6条回答
  •  佛祖请我去吃肉
    2020-12-18 14:15

    You should use the round() command to always round down the precision you want, otherwise some day you'll get something like 2.2000000000123 due to the nature of float arithmetic.

提交回复
热议问题