Task

Write a function to detect a   divide by zero error   without checking if the denominator is zero.




$ include "seed7_05.s7i";
  include "float.s7i";
 
const proc: doDivide (in integer: numer, in integer: denom) is func
  begin
    block
      writeln(numer <& " div " <& denom <& " = " <& numer div denom);
    exception
      catch NUMERIC_ERROR:
        writeln("Division by zero detected.");
    end block;
  end func;
 
const proc: doDivide (in float: numer, in float: denom) is func
  local
    var float: quotient is 0.0;
  begin
    quotient := numer / denom;
    if quotient <> Infinity and quotient <> -Infinity then
      writeln(numer <& " / " <& denom <& " = " <& quotient);
    else
      writeln("Division by zero detected.");
    end if;
  end func;
 
const proc: main is func
  begin
    doDivide(10, 8);
    doDivide(1, 0);
    doDivide(10.0, 8.0);
    doDivide(1.0, 0.0);
  end func;