Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006781 [Squeak] Kernel minor always 11-23-07 22:13 04-18-10 22:04
Reporter nicolas cellier View Status public  
Assigned To andreas
Priority normal Resolution fixed  
Status closed   Product Version 3.10
Summary 0006781: 0.0 raisedTo: -1.0 unexpected result
Description (0.0 raisedTo: -1) correctly raise a ZeroDivide

while

(0.0 raisedTo: -1.0) ... well, answer 0.0, hem...
Additional Information
Attached Files  FloatRaisedTo-M6781-nice-test.1.cs [^] (584 bytes) 12-01-07 17:10
 FloatRaisedTo-M6781-nice-patch.1.cs [^] (1,249 bytes) 12-01-07 17:10
 FloatRaisedTo-M6781-nice-patch.2.cs [^] (1,654 bytes) 12-01-07 18:07
 NumberRaisedTo-M6781-nice-test.1.cs [^] (561 bytes) 12-06-07 20:25
 NumberRaisedTo-M6781-nice-patch.1.cs [^] (937 bytes) 12-06-07 20:26
 NumberRaisedTo-M6781-nice-patch.2.cs [^] (987 bytes) 12-06-07 20:41

- Relationships

- Notes
(0011453 - 39 - 39 - 39 - 39 - 39 - 39)
nicolas cellier
11-23-07 22:14

Sorry Ken, forgot to classify Kernel...
 
(0011505 - 2010 - 3521 - 3521 - 3521 - 3521 - 3521)
nicolas cellier
12-01-07 18:06
edited on: 12-01-07 18:29

Note:

i checked what does C (libm.so.6) in these cases:
pow(negativeZero,zero) -> 1.0
    correct
pow(0.0,0.0) -> 1.0
    questionable could as well answer NaN or raise exception
    possible rationale: pow(-1.0/exp(100.0),0.0) will answer 1.0
    so does pow(+1.0/exp(100.0),0.0) (there is no Float positiveZero)
pow(zero,negativeZero) -> 1.0
    could as well be a division by zero
pow(negativeZero,0.5) -> 0.0
    could as well be NaN (a negative number raised to non integer power)
pow(negativeZero,1.0) -> -0.0
    correct
pow(nan,0.0) -> 1.0
    possibly a bug of libm. Squeak does the same
pow(0.0,nan) -> nan
    Here squeak does answer zero...
pow(0.0,inf) -> 0.0
    questionable could as well be nan
pow(inf,0.0) -> 1.0
    questionable could as well be nan

Note that libm pow seems to also handle raisedToInteger: case...


patch.1.cs does not exactly the same for negativeZero, so I upload patch.2.cs
but this raise a lot of questions when pushing IEEE 754 logic to the borders...
what is really in the standard anyway?


#include <math.h>
#include <stdio.h>

int main() {
        double nz=-1.0/exp(1.0e100);
        double nan=0.0/0.0;
        double inf=exp(100.0);
        printf("1.0/-0.0=%f\n",1.0/nz);
        printf("pow(0.0,0.0)=%f\n",pow(0.0,0.0));
        printf("pow(0.0,-0.0)=%f\n",pow(0.0,nz));
        printf("pow(-0.0,0.0)=%f\n",pow(nz,0.0));
        printf("pow(-0.0,0.5)=%f\n",pow(nz,0.5));
        printf("pow(-0.0,1.0)=%f\n",pow(nz,1.0));
        printf("pow(-1.0,0.5)=%f\n",pow(-1.0,0.5));
        printf("pow(nan,0.0)=%f\n",pow(nan,0.0));
        printf("pow(0.0,nan)=%f\n",pow(0.0,nan));
        printf("pow(0.0,-1.0)=%f\n",pow(0.0,-1.0));
        printf("pow(-0.0,-1.0)=%f\n",pow(nz,-1.0));
        printf("pow(0.0,inf)=%f\n",pow(0.0,inf));
        printf("pow(0.0,-inf)=%f\n",pow(0.0,-inf));
        printf("pow(inf,0.0)=%f\n",pow(inf,0.0));
        printf("pow(-inf,0.0)=%f\n",pow(-inf,0.0));
        return 0;
}

 
(0011518 - 341 - 365 - 365 - 365 - 365 - 365)
nicolas cellier
12-06-07 20:45

Number raisedTo: also has the bug.
Since Float>>#raisedTo: is one of the not-relicenced method (though nothing more than 99% copy-paste from super), the best thing is to simply remove it and arrange for super to return a Float when it has to (using ^self class one).

So pick NumberRaisedTo-M6781-nice-patch.2.cs and forget other patches.
 
(0011558 - 179 - 245 - 245 - 245 - 245 - 245)
Keith_Hodges
12-17-07 16:36
edited on: 12-17-07 17:08

"fix begin"
Installer mantis bug: 6781 fix:'NumberRaisedTo-M6781-nice-patch.2.cs'.
"fix test"
Installer mantis bug: 6781 fix:'NumberRaisedTo-M6781-nice-test.1.cs'.
"fix end"

 
(0013334 - 59 - 59 - 209 - 209 - 209 - 209)
nicolas cellier
10-04-09 20:05

Fixed in http://source.squeak.org/trunk/Kernel-nice.256.mcz [^]
 

- Issue History
Date Modified Username Field Change
11-23-07 22:13 nicolas cellier New Issue
11-23-07 22:13 nicolas cellier Status new => assigned
11-23-07 22:13 nicolas cellier Assigned To  => KenCausey
11-23-07 22:14 nicolas cellier Note Added: 0011453
11-24-07 22:32 KenCausey Assigned To KenCausey =>
11-24-07 22:32 KenCausey Status assigned => new
11-24-07 22:32 KenCausey Category Any => Kernel
11-24-07 22:32 KenCausey Description Updated
12-01-07 17:10 nicolas cellier File Added: FloatRaisedTo-M6781-nice-test.1.cs
12-01-07 17:10 nicolas cellier File Added: FloatRaisedTo-M6781-nice-patch.1.cs
12-01-07 18:06 nicolas cellier Note Added: 0011505
12-01-07 18:07 nicolas cellier File Added: FloatRaisedTo-M6781-nice-patch.2.cs
12-01-07 18:29 nicolas cellier Note Edited: 0011505
12-06-07 20:25 nicolas cellier File Added: NumberRaisedTo-M6781-nice-test.1.cs
12-06-07 20:26 nicolas cellier File Added: NumberRaisedTo-M6781-nice-patch.1.cs
12-06-07 20:41 nicolas cellier File Added: NumberRaisedTo-M6781-nice-patch.2.cs
12-06-07 20:45 nicolas cellier Note Added: 0011518
12-17-07 16:36 Keith_Hodges Note Added: 0011558
12-17-07 17:08 Keith_Hodges Note Edited: 0011558
01-10-09 02:00 Keith_Hodges Status new => pending
01-10-09 03:26 Keith_Hodges Status pending => testing
01-10-09 03:39 Keith_Hodges Status testing => resolved
01-10-09 03:39 Keith_Hodges Fixed in Version  => 3.11
01-10-09 03:39 Keith_Hodges Resolution open => fixed
01-10-09 03:39 Keith_Hodges Assigned To  => Keith_Hodges
01-10-09 03:41 Keith_Hodges Status resolved => testing
10-03-09 19:33 Keith_Hodges Status testing => assigned
10-03-09 19:33 Keith_Hodges Assigned To Keith_Hodges => andreas
10-04-09 20:05 nicolas cellier Status assigned => resolved
10-04-09 20:05 nicolas cellier Fixed in Version 3.11 => trunk
10-04-09 20:05 nicolas cellier Note Added: 0013334
04-18-10 22:04 andreas Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
87 total queries executed.
42 unique queries executed.
Powered by Mantis Bugtracker