RosettaCodeData/Task/Exponentiation-operator/Slate/exponentiation-operator-2.s...

9 lines
291 B
Plaintext

x@(Float traits) raisedTo: y@(Float traits)
"Implements floating-point exponentiation in terms of the natural logarithm
and exponential primitives - this is generally faster than the naive method."
[
y isZero ifTrue: [^ x unit].
x isZero \/ [y isUnit] ifTrue: [^ x].
(x ln * y) exp
].