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).
Seen on:
PHP
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026