Detect division by zero: Difference between revisions

m
(Added GW-BASIC and MSX Basic)
Line 2,544:
fn divide(x f64, y f64) {
result := x/y
if result.str().contains_any_substr(['"inf'",'"nan'"]) == true {
println("Can\'t divide by zero!'")
return
}
Line 2,571:
fn divide_error_handler(x f64, y f64) !f64 {
result := x/y
if result.str().contains_any_substr(['"inf'",'"nan'"]) == true {
return error('"Can\'t divide by zero!'")
}
return result
291

edits