Integer.st
changeset 5210 f56e448396f9
parent 5209 3a52e2f97ec4
child 5238 f7a816a660a3
--- a/Integer.st	Tue Jan 25 11:12:20 2000 +0100
+++ b/Integer.st	Tue Jan 25 11:52:51 2000 +0100
@@ -977,6 +977,23 @@
     "Modified: 5.11.1996 / 14:06:40 / cg"
 !
 
+changeBit:index to:aBooleanOrNumber
+    "return a new number where the specified bit is on or off,
+     sepending on aBooleanOrNumber.
+     Bits are counted from 1 starting with the least significant.
+     The methods name may be missleading: the receiver is not changed,
+     but a new number is returned. Should be named #withBitChanged:to:"
+
+    (aBooleanOrNumber == 0 or:[aBooleanOrNumber == false]) ifTrue:[
+        ^ self bitClear:index
+    ].
+    ^ self setBit:index
+
+    "
+     0 changeBit:3 to:1         => 4 (2r100)
+    "
+!
+
 clearBit:index
     "return a new number where the specified bit is off.
      Bits are counted from 1 starting with the least significant.
@@ -2570,6 +2587,6 @@
 !Integer class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.128 2000-01-25 10:12:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.129 2000-01-25 10:52:51 cg Exp $'
 ! !
 Integer initialize!