Ruby

Ruby

Made by DeepSource

Division by zero RB-E1009

Bug risk
Major
cwe-369

The division by zero error in Ruby occurs when an attempt is made to divide a number by zero. This issue arises due to the fundamental mathematical rule that division by zero is undefined. When the division operation encounters a denominator of zero, it leads to an error condition.

Bad practice

1 / 0
1. / 0
1. % 0
1.send(:/, 0)
30.quo 0

Recommended

1 / 2
1. / 10
20. % 39
1.send(:/, 42)
30.quo 5

References

  1. CWE-369: Divide By Zero