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

5 lines
160 B
Groovy
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
def dividesByZero = { double n, double d ->
assert ! n.infinite : 'Algorithm fails if the numerator is already infinite.'
(n/d).infinite || (n/d).naN
}