From owner-freebsd-hackers Wed Jan 5 11:57:20 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fysgr387.sn.umu.se (fysgr387.sn.umu.se [130.239.128.239]) by hub.freebsd.org (Postfix) with ESMTP id 532951509F for ; Wed, 5 Jan 2000 11:57:02 -0800 (PST) (envelope-from saska@fysgr387.sn.umu.se) Received: by fysgr387.sn.umu.se (Postfix, from userid 1000) id 585BBA837; Wed, 5 Jan 2000 20:59:47 +0100 (CET) Date: Wed, 5 Jan 2000 20:59:47 +0100 From: Markus Holmberg To: Martin Cracauer Cc: freebsd-hackers@freebsd.org Subject: Re: Should -mieee-fp equal fpsetmask(0) to avoid SIGFPE on FreeBSD? Message-ID: <20000105205947.A77037@fysgr387.sn.umu.se> References: <20000104121459.A8959@cons.org> <87632.947017515@monkeys.com> <20000105055138.A74746@fysgr387.sn.umu.se> <20000105092356.A8100@cons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000105092356.A8100@cons.org>; from cracauer@cons.org on Wed, Jan 05, 2000 at 09:23:57AM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Jan 05, 2000 at 09:23:57AM +0100, Martin Cracauer wrote: > > > > #define JSDOUBLE_IS_INT(d, i) (JSDOUBLE_IS_FINITE(d) && \ > > !JSDOUBLE_IS_NEGZERO(d) && ((d) == (i = (jsint)(d)))) > > Ah, OK, this macro is a conversion where the undefined result of the > (int)double_bigger_max_int is (intentionally) used as a speed hack of > a range check. Unfortunately I think it's used as more than just a range check. It also checks if the floating point part of the value is 0, as in a "true" integer, not just if the integer part is in range of the int type. > static inline int cra_is_int(const double d, int *const i) > { > if (d <= (double)INT_MAX && d >= (double)INT_MIN) { > *i = (int)d; > return 1; > } else > return 0; > } If this is used then for example the double 3.14159 would return true, when the intention was that it should return false, because the double has a floating point part, and hence cannot be stored as an integer without data loss. Martin, your solution looked great, but if my observations are correct I'm afraid we are back to square one with fpsetmask(). :( Of course, an option would be to add a check for the floating point part in Martin's suggested c function, but that would add a lot of overhead which the responsible people for this code won't accept since JSDOUBLE_IS_INT is a frequently used macro. If anyone got a suggestion for a clean way to do this check.. Speak up :). Markus -- Markus Holmberg | Give me UNIX or give me a typewriter. saska@acc.umu.se | http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message