Re: [xml] XPath Infinities
- From: Daniel Veillard <veillard redhat com>
- To: Bjorn Reese <breese mail1 stofanet dk>, Ray Strode <halfline hawaii rr com>
- Cc: xml gnome org
- Subject: Re: [xml] XPath Infinities
- Date: Sun, 29 Apr 2001 13:47:37 -0400
On Sun, Apr 29, 2001 at 07:24:10AM -1000, Ray Strode wrote:
double SetNaN()
{
return 0.0 / 0.0;
}
Actually, that may segfault on RedHat, too. It's very specific,
it only allows it when the variable is being initialized to it.
It SIGFPE's any other way. So double NaN = 0.0/0.0 will work,
but double NaN = SetNaN(), double NaN = 0/0,and double NaN; NaN /= 0.0,
won't.
yep, what I ultimately want is the following sequence of code:
save 0/1/-1 to an FP
divide this FP by the value 0
it is impossible to avoid compiler "optimization", except maybe by calling
a function which would do the divide by 0 (compiler are unlikely to try
to solve this at compilation time. So the solution is probably to do something
like:
/* keeping the function public to absolutely avoid the compiler from trying
global optimization on this. */
float xmlXPathDivideBy(float f, float fzero) {
float ret;
#ifdef HAVE_SIGNAL
#ifdef SIGFPE
#ifdef SIG_IGN
void (*sighandler)(int);
sighandler = signal(SIGFPE, SIG_IGN);
#endif
#endif
#endif
ret = f / fzero;
#ifdef HAVE_SIGNAL
#ifdef SIGFPE
#ifdef SIG_IGN
signal(SIGFPE, sighandler);
#endif
#endif
#endif
}
xmlXPathInit()
...
float f, fzero;
f = 0/1/-1;
fzero = 0.0;
f = xmlXPathDivideByZero(f, fzero);
...
NB: restauring the signal is really important for libxml to be seen as a
well behaved library :-)
If both of you could check this solution I think it's the best to do
(should work with MS compiler too).
Daniel
--
Daniel Veillard | Red Hat Network http://redhat.com/products/network/
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]