QuadraticImpl.mesa
Written by Michael Plass, 11-Nov-81 11:30:07
DIRECTORY RealFns USING [SqRt], Quadratic;
QuadraticImpl: PROGRAM IMPORTS RealFns EXPORTS Quadratic =
BEGIN
Roots: TYPE = Quadratic.Roots;
RealRoots:
PUBLIC
PROCEDURE [a,b,c:
REAL]
RETURNS [Roots] =
BEGIN
IF a#0
THEN
BEGIN
d: REAL;
b ← b/a;
c ← c/a;
a ← 1.0;
d ← b*b-4*c;
IF d<0 THEN RETURN [[0,99.9,99.9]];
d ← RealFns.SqRt[d];
RETURN[[2,(-b-d)/2,(-b+d)/2]];
END
ELSE IF b#0 THEN RETURN[[1,-c/b,99.9]]
ELSE RETURN[[0,0.0,0.0]]
END;
END.