Thanks Koos. This description is indeed wrong.
On Tue, Jul 18, 2017 at 8:47 PM, Koos Brandt <[email protected]> wrote: > Hi > > I am new to this environment > > I am on Pharo 6.0 - 64 Mac OSX version, Downloaded over the weekend. > > Just did some learning and found that the description for bitAnd: is > probably wrong. > > It reads exactly the same as bitOr: > > here are some tests as performed in the workspace > Also included bitXor: for the fun of it > > bitAnd: arg > Primitive. Answer an Integer whose bits are the logical OR of the > receiver's bits and those of the argument, arg. > Numbers are interpreted as having 2's-complement representation. > Essential. See Object documentation whatIsAPrimitive. > <primitive: 14> > self >= 0 ifTrue: [^ arg bitAnd: self]. > ^ (self bitInvert bitOr: arg bitInvert) bitInvert. > 0 bitAnd: 0 -> 0 > 1 bitAnd: 0 -> 0 > 2 bitAnd: 0 -> 0 > 3 bitAnd: 0 -> 0 > 0 bitAnd: 1 -> 0 > 1 bitAnd: 1 -> 1 > 2 bitAnd: 1 -> 0 > 3 bitAnd: 1 -> 1 > > bitOr: arg > Primitive. Answer an Integer whose bits are the logical OR of the > receiver's bits and those of the argument, arg. > Numbers are interpreted as having 2's-complement representation. > Essential. See Object documentation whatIsAPrimitive. > <primitive: 15> > self >= 0 ifTrue: [^ arg bitOr: self]. > ^ arg < 0 > ifTrue: [(self bitInvert bitAnd: arg bitInvert) bitInvert] > ifFalse: [(self bitInvert bitClear: arg) bitInvert] > 0 bitOr: 0 -> 0 > 1 bitOr: 0 -> 1 > 2 bitOr: 0 -> 2 > 3 bitOr: 0 -> 3 > 0 bitOr: 1 -> 1 > 1 bitOr: 1 -> 1 > 2 bitOr: 1 -> 3 > 3 bitOr: 1 -> 3 > > bitXor: arg > Primitive. Answer an Integer whose bits are the logical XOR of the > receiver's bits and those of the argument, arg. > Numbers are interpreted as having 2's-complement representation. > Essential. See Object documentation whatIsAPrimitive. > <primitive: 16> > self >= 0 ifTrue: [^ arg bitXor: self]. > ^ arg < 0 > ifTrue: [self bitInvert bitXor: arg bitInvert] > ifFalse: [(self bitInvert bitXor: arg) bitInvert]. > 0 bitXor: 0 -> 0 > 1 bitXor: 0 -> 1 > 2 bitXor: 0 -> 2 > 3 bitXor: 0 -> 3 > 0 bitXor: 1 -> 1 > 1 bitXor: 1 -> 0 > 2 bitXor: 1 -> 3 > 3 bitXor: 1 -> 2 > > Picked it up when I was trying to explain the simplicity of the even method > on smallInteger. > > Methods work just fine, but the description is wrong > > regards > Koos brandt >
