Date: Fri, 30 Dec 1994 16:04:19 -0500 From: Thomas David Rivers <rivers%ponds@ncren.net> To: markd@grizzly.com, rivers%ponds@ncren.net Cc: freebsd-questions@freebsd.org Subject: Re: Behavior of sqrt on errors. Message-ID: <199412302104.QAA03529@ponds.UUCP>
next in thread | raw e-mail | index | archive | help
> > >> On FreeBSD, > >> > >> sqrt (-3.0); > >> > >> generates a SIGFPE. On all other systems I have encountered, it calls > >> matherr with a DOMAIN error. Can anyone more knowledgeable about the > >> ANSI standard comment if this correct ANSI behavior or a bug? > > > From the sqrt(3) man page: > > > > The sqrt() function > > returns the requested square root unless an error occurs. On the VAX or > > Tahoe processor an attempt to take the sqrt() of negative x causes an er- > > ror; in this event, the global variable errno is set to EDOM and a re- > > served operand fault is generated. > > > > So, the man page implies this is working as designed. > > Thanks. I did see this, but all other Unix systems I have tried go to matherr. > In fact, this has to do with software (Tcl) that is ported to virtually > every Unix platform. In all of those implementations, either matherr or > returning a NAN (not-a-number) value is used to report the error. > I have seen the port of Tcl on ftp.freebsd.org, it does a fpsetmask(0) > to prevent the exception, but then the errors are not reported back > to the Tcl interpreter, instead invalid data is passed back. > Since the next release of Tcl is in beta right now, I would like to come up > with a solution that can be incorporated into the release. Hmm.. I wonder what Tcl does under BSD on the VAX? The man page would imply that either it hasn't been ported there, or doesn't work. I would change Tcl to catch the SIGFPE and check errno. Also, I wonder what the Sun libm does... it may act differently than the BSD version. If so, you could link Tcl with that libm instead. > > Anyone know anything about this? > > Mark > - Just a suggestion - - Dave Rivers -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199412302104.QAA03529>