From owner-freebsd-questions Fri Dec 30 12:29:42 1994 Return-Path: questions-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id MAA00294 for questions-outgoing; Fri, 30 Dec 1994 12:29:42 -0800 Received: from upr2.clu.net (upr2.clu.net [136.145.2.4]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id MAA00288 for ; Fri, 30 Dec 1994 12:29:40 -0800 Received: by upr2.clu.net (/\==/\ Smail3.1.28.1 #28.13) id ; Fri, 30 Dec 94 16:28 EST Received: from ldc (localhost) by uwi.tt (5.0/SMI-SVR4) id AA05740; Fri, 30 Dec 1994 12:43:35 +0400 Message-Id: <9412300843.AA05740@uwi.tt> To: freebsd-questions@freebsd.org Subject: Re: Behavior of sqrt on errors. Date: Fri, 30 Dec 1994 12:43:34 +0400 From: Feisal Mohammed content-length: 900 Sender: questions-owner@freebsd.org Precedence: bulk Hi, Mark Diekhans said, >>> 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? > 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) I use RLaB (a Matlab-like prog) under SunOS and also FreeBSD. The differences of the implementation causes the floating pt. errors to be handled less cleanly, e.g. 0/0 returns NAN on SunOS and a floating exception on FreeBSD, same for sqrt(). Clearly the better way is through the use of matherr as in SunOS. -Feisal