# How to divide by a float in PHP?

384

I need to determine if a given number`x`

is divisble by`y`

in PHP, being`y`

a float, specifically 0.05.

But when I do it,

```
if ($number % 0.05 === 0) {
// Continue
}
```

I recieve the following PHP warning:

Division by zero

What can I do to solve this? Thanks!

## Answer

## Solution:

The definision of modulus is as follows:

Another way of expressing

`a % b`

is:`a - b * floor(a/b)`

Therefore, you could define your own function:

And simply call it. For example, calling

`mod(0.08,0.05)`

will return`0.03`

.## Answer

## Solution:

You could multiply both numbers by 100.