# Deprecated: Implicit conversion from float 2.5 to int loses precision

**Code:** `Implicit float to int` · **Category:** PHP · **Seen on:** PHP

PHP 8.1+ warns when a float with a fractional part is silently converted to int (array keys, % operator, int parameters).

## 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

1. Round explicitly: `(int) round($x)` or `intdiv()`
2. Use fmod() for float modulo

## Detailed fix by platform

### PHP

1. `$page = (int) floor($offset / $perPage);`

## How to diagnose

1. **Expression** — Which conversion?
2. **Intent** — Truncate, round or keep decimals?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/implicit-conversion-float-to-int-deprecated)
