🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4611

Re: Microsoft C actually does something better!

#4611
From: Anders Thulin
Date: Thu, 07 Feb 1991 12:14
39 lines
2024 bytes
In article <8904@sail.LABS.TEK.COM> toma@sail.LABS.TEK.COM (Tom Almy) writes:

>Case 1: { double x=1e200; printf("%g",x*x); }
>(With some compilers, the 80x87 has to have the overflow trap masked off).
>
>Microsoft C (V6.00A): prints +inf	(correct!)
>Microway NDP C-386 (V1.4e): prints -*inf** (wrong sign!?!)
>Metaware High C DOS 386 (V1.62): prints infinity (correct!)
>Turbo C (C++ V1.0): hangs, requiring "three fingered salute".
>Zortech C (V2.18): prints 1.797693e+308

Why is 'infinity' the correct answer? I don't think ANSI C says
anything about that, so the Zortech answer may be 'as correct' as the
Microsoft or Metware.

>Case 2: { double x=1e50; x = sin(x); printf("%g", x);}
>( matherr() function defined where available )
>
>Microsoft: sine function causes error "Total loss of significance" (correct!)
>Microway: crashes, producing register dump, executing sine function.
>Metaware: with inline 80387 code, 1e50; with fp library, NaN (ok.)
>Turbo C: sine function causes error "Domain" (wrong error)
>Zortech C: prints garbage answer.

A suggestion:

In an ANSI C environment, you must clear errno before the invocation
of sin, and test it afterwards to detect any errors. As I don't see
it in your code, I suspect you didn't use it.

Naturally, 'correctness' must be relative some standard. I assume ANSI C,
but you may have chosen something different.




-- 
Anders Thulin       ath@linkoping.telesoft.se 
Telesoft Europe AB, Teknikringen 2B, S-583 30 Linkoping, Sweden
Technical Details
Message-ID: <730@castor.linkoping.telesoft.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!cs.utexas.edu!rice!uupsi!sunic!liuida!mailhost!ath
References: <8904@sail.LABS.TEK.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!cs.utexas.edu!rice!uupsi!sunic!liuida!mailhost!ath
From: ath@linkoping.telesoft.se (Anders Thulin)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Microsoft C actually does something better!
Message-ID: <730@castor.linkoping.telesoft.se>
Date: 7 Feb 91 12:14:52 GMT
References: <8904@sail.LABS.TEK.COM>
Organization: TeleSoft AB, Linkoping, Sweden
Lines: 39