tonelm54

asked on

# Modulus but not full ints

Im trying to figure out how to modulus with decimal places.

But keep getting

The issue I have is the "3*0.25" can be "2*0.25" or "5*0.25" or any other number, so I cant multiply into full number

For example:-

Should give 0.25, but instead gives 0

Any ideas?

```
$totTime = 1;
$modDivisor = 3 * 0.25;
echo "Total Time: " . $totTime . "<br/>";
echo "Divosor: " . $modDivisor . "<br/>";
echo $totTime % $modDivisor;
```

But keep getting

FATAL ERROR Uncaught DivisionByZeroError: Modulo by zero in /home4/phptest/public_html/code.php7 0(5) : eval()'d code:7 Stack trace: #0 /home4/phptest/public_html /code.php7 0(5): eval() #1 {main} thrown on line number 7

The issue I have is the "3*0.25" can be "2*0.25" or "5*0.25" or any other number, so I cant multiply into full number

For example:-

```
php
$totTime = 1;
$modDivisor = 5 * 0.25;
echo "Total Time: " . $totTime . "<br/>";
echo "Divosor: " . $modDivisor . "<br/>";
echo $totTime % $modDivisor;
```

Should give 0.25, but instead gives 0

Any ideas?

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

Open in new window

Just move the numbers into the integer domain by multiplying by 100