[BUGLET] in Float>raisedTo:

Florin Mateoc Florin at integral.com
Sat Feb 20 00:02:57 UTC 1999

You are right, but it's more than that. It is also not correct to raise
a negative number to a float and if we take care of the integer powers
first #ln will take care of enforcing just that (so abs is not necessary).
Revised version:

	self = 0 ifTrue: [
		aNumber negative
			ifTrue: [^self error: 'attempt to divide by zero']
			ifFalse: [
				aNumber = 0
					ifTrue: [
						^self error: '0 raisedTo:
					ifFalse: [
	(aNumber actuallyInteger)
		ifTrue: ["Do the special case of integer power"
				^self raisedToInteger: aNumber asInteger].
	^(aNumber asFloat * self ln) exp


-----Original Message-----
From: sqrmax at cvtci.com.ar [mailto:sqrmax at cvtci.com.ar]
Sent: Friday, February 19, 1999 6:01 PM
To: squeak at cs.uiuc.edu
Subject: Re: RE: [BUGLET] in Float>raisedTo:


>I would vote for something like: [...]
>	^(aNumber asFloat * self abs ln) exp * self sign
>"Otherwise raise it to the power using logarithms"

Don't forget to check if self = 0.0... it's not correct to send ln to 0.0.


More information about the Squeak-dev mailing list