[BUGLET] in Float>raisedTo:

Pat Caudill patc at teleport.com
Mon Feb 22 15:19:09 UTC 1999

>I would vote for something like:
>  raisedTo: aNumber 
>	"Answer the receiver raised to aNumber."
>	(aNumber actuallyInteger) "not just for class Integer, but also for
>x.0 or x/1"
>		ifTrue: ["Do the special case of integer power"
>				^self raisedToInteger: aNumber asInteger].
>"this would also take care of special cases 0 and 1"
>	^(aNumber asFloat * self abs ln) exp * self sign
>"Otherwise raise it to the power using logarithms"

I'm not sure this is right. It would give -1 as the square root of -1. 
((-1) raisedTo: 0.5)

If the number is negative and the power is not an integer I think it 
should be an error.
I would vote for a special error in this case rather than log of a 
negative number.

Pat Caudill

More information about the Squeak-dev mailing list