Deprecated: Implicit conversion from float 2.5 to int loses precision
PHP 8.1+ warns when a float with a fractional part is silently converted to int (array keys, % operator, int parameters).
Implicit conversion from floatloses precision Meaning
Using floats as array keys or with modulo truncates them. PHP 8.1 makes the precision loss visible.
Common causes
- Float used as an array key
- Modulo with float operands
- Float passed to an int parameter
⚡ Quick fix
- Round explicitly:
(int) round($x)orintdiv() - Use fmod() for float modulo
Detailed fix by platform
PHP
$page = (int) floor($offset / $perPage);
How to diagnose
- Expression — Which conversion?
- Intent — Truncate, round or keep decimals?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026