--- a/Number.st Sat Mar 06 12:27:34 2010 +0100
+++ b/Number.st Sat Mar 06 12:29:09 2010 +0100
@@ -1222,17 +1222,21 @@
!
timesTwoPower:anInteger
- "Return the receiver multiplied by 2.0 raised to the power of the argument.
+ "Return the receiver multiplied by 2 raised to the power of the argument.
For protocol completeness wrt. Squeak and ST80."
- ^ self * (2.0 raisedToInteger:anInteger)
+ anInteger >= 0 ifTrue:[
+ ^ self * (1 bitShift:anInteger)
+ ].
+ ^ self / (1 bitShift:anInteger negated)
"
- 123 timesTwoPower:0
- 123 timesTwoPower:1
- 123 timesTwoPower:2
- 123 timesTwoPower:3
- (2.0 timesTwoPower: -150) timesTwoPower: 150
+ 123 timesTwoPower:0 -> 123
+ 123 timesTwoPower:1 -> 246
+ 123 timesTwoPower:2 -> 492
+ 123 timesTwoPower:3 -> 984
+
+ (2 timesTwoPower: -150) timesTwoPower: 150 -> 2
"
! !
@@ -2246,9 +2250,9 @@
!Number class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.131 2010-03-06 10:05:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.132 2010-03-06 11:29:09 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.131 2010-03-06 10:05:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.132 2010-03-06 11:29:09 cg Exp $'
! !