'From Squeak3.10beta of 22 July 2007 [latest update: #7137] on 1 December 2007 at 6:16:46 pm'!
"Change Set: FloatRaisedTo-M6781-nice-patch
Date: 1 December 2007
Author: nice
(0.0 raisedTo: -1). correctly raise a ZeroDivide
(0.0 raisedTo: -1.0) ... well, answer 0.0, hem...
This is a patch"!
!Float methodsFor: 'mathematical functions' stamp: 'nice 12/1/2007 18:16'!
raisedTo: aNumber
"Answer the receiver raised to aNumber."
aNumber isInteger ifTrue:
["Do the special case of integer power"
^ self raisedToInteger: aNumber].
self < 0.0 ifTrue:
[ ArithmeticError signal: ' raised to a non-integer power' ].
0.0 = aNumber ifTrue: [^ 1.0]. "special case for exponent = 0.0"
self= 0.0 ifTrue: [ "special case for self = 0.0"
"NOTE: (0.0 raisedTo: 0.0) will answer zero, as do other languages and libraries like C libm pow(0.0,0.0)
This is questionable, it could as well raise an Exception or answer NaN.
(Float negativeZero raisedTo: anything will answer itself, which is also questionable"
aNumber < 0.0
ifTrue: [^ (ZeroDivide dividend: self) signal]
ifFalse: [^ self]].
aNumber = 1.0 ifTrue: [^ self]. "special case for exponent = 1.0"
^ (self ln * aNumber asFloat) exp "otherwise use logarithms"
! !