Date: Wed, 5 Jan 2000 20:59:47 +0100 From: Markus Holmberg <saska@acc.umu.se> To: Martin Cracauer <cracauer@cons.org> 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> In-Reply-To: <20000105092356.A8100@cons.org>; from cracauer@cons.org on Wed, Jan 05, 2000 at 09:23:57AM %2B0100 References: <20000104121459.A8959@cons.org> <87632.947017515@monkeys.com> <20000105055138.A74746@fysgr387.sn.umu.se> <20000105092356.A8100@cons.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000105205947.A77037>