--- a/Number.st Thu Feb 25 22:58:21 2010 +0000
+++ b/Number.st Mon Mar 08 21:39:02 2010 +0000
@@ -1222,16 +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
+ 123 timesTwoPower:0 -> 123
+ 123 timesTwoPower:1 -> 246
+ 123 timesTwoPower:2 -> 492
+ 123 timesTwoPower:3 -> 984
+
+ (2 timesTwoPower: -150) timesTwoPower: 150 -> 2
"
! !
@@ -2245,14 +2250,15 @@
!Number class methodsFor:'documentation'!
version
- ^ '$Id: Number.st 10501 2010-02-13 23:34:44Z vranyj1 $'
+ ^ '$Id: Number.st 10505 2010-03-08 21:39:02Z vranyj1 $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/Number.st,v 1.130 2010/02/10 17:45:30 cg Exp §'
+ ^ '§Header: /cvs/stx/stx/libbasic/Number.st,v 1.132 2010/03/06 11:29:09 cg Exp §'
! !
+