The upgrade notes for Laravel 11 say:
The float column type now creates a
FLOATequivalent column without total digits and places (digits after decimal point), but with an optional$precisionspecification to determine storage size as a 4-byte single-precision column or an 8-byte double-precision column. Therefore, you may remove the arguments for$totaland$placesand specify the optional$precisionto your desired value and according to your database's documentation:$table->float('amount', precision: 53);
However, the database documentation doesn't provide any explanation for what the precision argument might represent or why it defaults to 53. What effect will changing the value have on the resulting column?
Wasn't planning on a self-answer, but I thought to check MySQL's documentation and got an answer:
For
FLOAT, the SQL standard permits an optional specification of the precision (but not the range of the exponent) in bits following the keywordFLOATin parentheses, that is,FLOAT(p). MySQL also supports this optional precision specification, but the precision value inFLOAT(p)is used only to determine storage size. A precision from 0 to 23 results in a 4-byte single-precisionFLOATcolumn. A precision from 24 to 53 results in an 8-byte double-precisionDOUBLEcolumn.
So I think this means my old migrations with $table->float('price', 6) should continue to work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With