Modulus operator is supposed to show the remainder. Like for echo(34%100)
outputs 34
. But why do i get a "Division by zero
" error for this code echo(34%4294967296)
error when a number is divided by zero (0). It happens when you enter a simple formula like =5/0, or when a formula refers to a cell that has 0 or is blank, as shown in this picture. To correct the error, do any of the following: Make sure the divisor in the function or formula isn't zero or a blank cell.
Conclusion # The Python "ZeroDivisionError: integer division or modulo by zero" occurs when we use the modulo % operator with an integer and a zero. To solve the error, figure out where the 0 comes from and correct the assignment.
The Python "ZeroDivisionError: float division by zero" occurs when we try to divide a floating-point number by 0 . To solve the error, use an if statement to check if the number you are dividing by is not zero, or handle the error in a try/except block.
What should that user's ratio be in this case? The most sane would be to check if the divisor is zero before doing the division. Otherwise, you could create a custom function for division like mydivide() and handle the zero case there.
4294967296
is 2^32
and cannot be represented as 32 bit number - it wraps back to 0. If you use 64-bit version of PHP, it may work.
You might be able to use floating point modulus fmod to get what you want without overflowing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With