[M3devel] Possible Bug?
Rodney M. Bates
rodney.m.bates at cox.net
Wed May 6 16:01:11 CEST 2009
Still, if we have library functions that crash, we should document
that somewhere reasonably conspicuous. It is really false advertising
and a trap for a programmer to put something in an interface and
then disable it.
It is not enough to just have alternative square root functions that work.
A newcomer to the language should not have to ferret this kind of
thing out by systematic linear search of all the libraries. The same
place that documents the broken functions should give pointers to
the alternatives.
Martin Bishop wrote:
> I have this code, for finding the roots of a quadratic equation:
>
> MODULE Quad EXPORTS Main;
>
> IMPORT IO, Fmt, RealSqrt;
>
> TYPE Roots = ARRAY [1..2] OF REAL;
>
> VAR r: Roots;
>
> PROCEDURE Solve(a, b, c: REAL): Roots =
> VAR sd: REAL := RealSqrt.Sqrt(b * b - 4.0 * a * c);
> x: REAL;
> BEGIN
> IF b < 0.0 THEN
> x := (-b + sd) / 2.0 * a;
> RETURN Roots{x, c / (a * x)};
> ELSE
> x := (-b - sd) / 2.0 * a;
> RETURN Roots{c / (a * x), x};
> END;
> END Solve;
>
> BEGIN
> r := Solve(1.0, -10.0E5, 1.0);
> IO.Put("X1 = " & Fmt.Real(r[1]) & " X2 = " & Fmt.Real(r[2]) & "\n");
> END Quad.
>
> When I try to build it, I get:
>
> ***
> *** runtime error:
> *** <*ASSERT*> failed: FloatMode.SetRounding not implemented
> *** file "../src/float/IEEE-default/FloatMode.m3", line 14
> ***
>
> Aborted
>
>
> I'm using:
>
> martin at thinkpad:~/Code/Modula-3/Test$ cm3 -version
> Critical Mass Modula-3 version d5.7.1
> last updated: 2009-01-21
> compiled: 2009-04-01 13:11:43
> configuration: /usr/local/bin/cm3.cfg
>
> which was installed from Jay's "std" binary package.
>
More information about the M3devel
mailing list