[M3devel] Possible Bug?

Jay jay.krell at cornell.edu
Wed May 6 03:31:29 CEST 2009


This has never worked on most platforms.
  We even deliberately stopped it working where it did -- e.g. SPARC.
We could fix it maybe.
 
 
Please try RealFloat.sqrt instead.
 
 
It is almost the same thing, but for lack of ability to use single precision, and is likely to be much much faster (how common is hardware sqrt? Anyway, vendor software sqrt is presumably excellent).
 
 
In future please give callstacks.
Run it under gdb or dbx, etc.
 
 
 - Jay



----------------------------------------
> Date: Tue, 5 May 2009 19:57:43 -0500
> From: martinbishop at bellsouth.net
> To: m3devel at elegosoft.com
> Subject: [M3devel] Possible Bug?
>
> 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:
> ***  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