[M3devel] Possible Bug?

Jay jay.krell at cornell.edu
Wed May 6 03:38:47 CEST 2009


I suggest we provide Cmath.i3 and/or Cfloat.i3 to provide trivial portable wrappers to some of this stuff in an easier to find location instead of buried. Granted, the buriers were trying to make things better in their way.
 
 
And by portable, I'd limit myself probably to
double foo(double);
 
 
and not likely delve into single precision functions, unless maybe
float foof(float) is fairly portable.
 
Eh, since they'd all be external, you can delcare them all and not necessarily implement all of them.
 
 
In any case the perf might stink compared to C.
Visual C++ for example can generate FPU instructions inline such as for sqrt.
gcc probably does a good job here too.
We'll likely incur function calls for portability.
 
 
Imho we need to do better with keeping up with "builtin functions" that C compilers gradually accrue and implement very well.
It is difficult though, for reasons of portability.
 
 
 - Jay

----------------------------------------
> From: jay.krell at cornell.edu
> To: martinbishop at bellsouth.net; m3devel at elegosoft.com
> Subject: RE: [M3devel] Possible Bug?
> Date: Wed, 6 May 2009 01:31:29 +0000
>
>
> 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