From owner-freebsd-questions Fri Dec 30 13:26:41 1994 Return-Path: questions-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id NAA01094 for questions-outgoing; Fri, 30 Dec 1994 13:26:41 -0800 Received: from reggae.ncren.net (reggae.ncren.net [128.109.131.3]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id NAA01086 for ; Fri, 30 Dec 1994 13:26:39 -0800 Received: from ponds.UUCP by reggae.ncren.net (5.65/tas-reggae/may94) id AA12498; Fri, 30 Dec 94 16:26:23 -0500 Received: (rivers@localhost) by ponds.UUCP (8.6.9/8.6.5) id QAA03529; Fri, 30 Dec 1994 16:04:19 -0500 Date: Fri, 30 Dec 1994 16:04:19 -0500 From: Thomas David Rivers Message-Id: <199412302104.QAA03529@ponds.UUCP> To: markd@grizzly.com, rivers%ponds@ncren.net Subject: Re: Behavior of sqrt on errors. Cc: freebsd-questions@freebsd.org Sender: questions-owner@freebsd.org Precedence: bulk > > >> 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 -