[net.bugs.4bsd] libm---log

hubert@entropy.UUCP (Steve Hubert) (02/08/85)

Libm says log(negative) = -HUGE and sqrt(negative) = 0.
Both set errno = EDOM which is reasonable.  I guess the values
0 and -HUGE must come from the idea that the functions should
be continuous at zero or some voodoo like that.

If I am not mistaken, Fortran programmers are used to being yelled at
when they try to pass an out-of-domain argument to a function.
C programmers, as always, are a different story.  Anyway, does anyone,
besides me, think it would be a good idea to explicitly warn the user
when s/he attempted to call log with a negative argument?  If so,
have you come up with a smooth way of doing it?

Steve Hubert
 Dept. of Stat., U. of Wash, Seattle
 {allegra,decvax,ihnp4,ucbvax!lbl-csam}!uw-beaver!entropy!hubert
 hubert%entropy@uw-beaver

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (02/11/85)

> Anyway, does anyone,
> besides me, think it would be a good idea to explicitly warn the user
> when s/he attempted to call log with a negative argument?  If so,
> have you come up with a smooth way of doing it?

Yes, on UNIX System V there is a matherr(3M) library function that
is invoked when a math library routine detects an error.  By default
it prints an appropriate warning message on stderr.  The programmer
can provide his own matherr() and do whatever he thinks is appropriate
upon occurrence of a math library error.

pedz@smu.UUCP (02/21/85)

I thought that on a Vax with 4.2 there was a whole set of signal
codes (plus one signal) which is used for floating point errors.
Why not pick the appropriate signal along with its code and send
it out?  I do not know how to get the code of the error in with
the signal since I do not remember that with the kill call but
in any case, I would make it an "interrupt" not a error or flag
which must be tested everywhere.

Perry
convex!smu!pedz