Date: Thu, 29 Dec 1994 22:09:17 -0800 From: Mark Diekhans <markd@grizzly.com> To: rivers%ponds@ncren.net Cc: freebsd-questions@freebsd.org Subject: Re: Behavior of sqrt on errors. Message-ID: <199412300609.WAA27159@Grizzly.COM> In-Reply-To: <199412300233.VAA19033@ponds.UUCP> (message from Thomas David Rivers on Thu, 29 Dec 1994 21:33:21 -0500)
next in thread | previous 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. Anyone know anything about this? Mark
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199412300609.WAA27159>