且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel(或PHP/MySQL?)减少小数点后的浮点数

更新时间:2023-02-21 16:27:07

实际上,float/double不如十进制精确.对于货币数据,建议使用十进制类型,因此您应该使用:

Actually float/double is not as precise as decimal. For monetary data, the decimal type is recommended, so you should probably use:

$table->decimal(10, 2); // instead of float

阅读有关详细信息,以及来自MySql的浮动手册.

Read this for some detailed information and float manual from MySql.