Skip to content

Commit e54f767

Browse files
committed
Add missing bit ops
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
1 parent 083133b commit e54f767

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

pkg/lang/numbers.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ func (nm *NumberMethods) AndNot(x, y any) any {
106106
return bitOpsCast(x) &^ bitOpsCast(y)
107107
}
108108

109+
func (nm *NumberMethods) Not(x any) any {
110+
return ^bitOpsCast(x)
111+
}
112+
113+
func (nm *NumberMethods) Or(x, y any) any {
114+
return bitOpsCast(x) | bitOpsCast(y)
115+
}
116+
117+
func (nm *NumberMethods) Xor(x, y any) any {
118+
return bitOpsCast(x) ^ bitOpsCast(y)
119+
}
120+
121+
func (nm *NumberMethods) SetBit(x, y any) any {
122+
return bitOpsCast(x) | (1 << bitOpsCast(y))
123+
}
124+
109125
func IsZero(x any) bool {
110126
return Ops(x).IsZero(x)
111127
}
@@ -146,10 +162,6 @@ func (nm *NumberMethods) ClearBit(x, y any) int64 {
146162
return bitOpsCast(x) & ^(1 << bitOpsCast(y))
147163
}
148164

149-
func (nm *NumberMethods) SetBit(x, y any) int64 {
150-
return bitOpsCast(x) | (1 << bitOpsCast(y))
151-
}
152-
153165
func (nm *NumberMethods) ShiftLeft(x, y any) int64 {
154166
x64, y64 := bitOpsCast(x), bitOpsCast(y)
155167
return x64 << (y64 & 0x3f)

0 commit comments

Comments
 (0)