www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/08/06/11:06:48

Date: Thu, 6 Aug 92 16:28:32 +0200
From: kunst AT prl DOT philips DOT nl
To: dj AT ctron DOT com
Subject: pow(-2,3) bug
Reply-To: kunst AT prl DOT philips DOT nl

Hello DJ,

> >    (2) The pow(x,y) function crashes (Exception 117) on
> >        negative x values, e.g. pow(-2,3).
> >        Is this an old bug ?
> >        (Note: the 'libsrc/m/exp.s' file in my distribution
> >         was changed by 'roberto AT germinal DOT ibp DOT fr' on 03-Apr-1991)
> 
> 117 is a floating point exception, as raising negative numbers in pow
> should be.

I do not totally agree with this, I'm afraid.
I don't have the 'official' C reference, but K&R (2nd ed.) state at p.251:

  pow(x,y)  x^y.  A domain error occurs if x=0 and y<=0,
	    or if x<0 and y is not an integer.

I assume from this that 'pow(-2,3)' returns '-8', as is the case on
the HP system I'm also working on.

>
> 1.07 is the latest.  See below for e-mail access.
>

I missed the e-mail 'below'. You don't mean 'dj AT ctron DOT com', do you ?


Thanks.

PS: should I revise 'exp.s' to make a contribution to your program  ?

/-----------------------------------------------------------------------/
/ Name : Pieter Kunst                                                   /
/ Email: kunst AT prl DOT philips DOT nl                                           /
/-----------------------------------------------------------------------/



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019