PHP - Serialize floating points

前端 未结 9 1474
自闭症患者
自闭症患者 2021-01-02 02:19

I am generating 10 random floats between 6 and 8 (all for good reason), and writing them to a mysql database in a serialized form. But one quirk seems to emerge at the stora

9条回答
  •  轮回少年
    2021-01-02 03:02

    Store them as strings after using number_format:

    $number = number_format($float, 2);
    

提交回复
热议问题