RosettaCodeData/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-1.groovy

5 lines
160 B
Groovy
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def dividesByZero = { double n, double d ->
assert ! n.infinite : 'Algorithm fails if the numerator is already infinite.'
(n/d).infinite || (n/d).naN
}