Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mailrus!utah-gr!uplherc!sp7040!obie!wes From: wes@obie.UUCP (Barnacle Wes) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs C for computations Summary: A simple example? Message-ID: <183@obie.UUCP> Date: 16 Sep 88 05:06:34 GMT References: <535@nikhefh.hep.nl> <356@quintus.UUCP> Organization: the Well of Souls Lines: 35 In article <535@nikhefh.hep.nl> t68@nikhefh.hep.nl (Jos Vermaseren) writes: > float x = -2.0; > z = sqrt(x); > > gives back some value. Amazingly enough many UNIX vendors like this > philosophy, so even the UNIX fortran compilers often prefer it this way. In article <356@quintus.UUCP>, ok@quintus.uucp (Richard A. O'Keefe) writes: % (1) See "matherr" in the System V documentation. If you define a function % int matherr(struct exception *x) it will be called when math library % functions detect a problem. As a matter of fact, the V.2 documentation for matherr(3m) addresses the sqrt "problem" directly: #includeint matherr(x) register struct exception *x; { switch (x->type) { case DOMAIN: /* change sqrt to return sqrt(-arg1), not 0 */ if (!strcmp(x->name, "sqrt")) { x->retval = sqrt(-(x->arg1)); return 0; } /* other cases follow here... */ } return 0; /* all other errors execute default procedure */ } -- {hpda, uwmcsd1}!sp7040!obie!wes "How do you make the boat go when there's no wind?" -- Me --