Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitwise Operators in GAP

Is one able to to use bitwise operators in the GAP programming language? For example, in Python one can do the following:

a = 60            # 60 = 0011 1100 
b = 13            # 13 = 0000 1101 
c = 0

c = a & b;        # 12 = 0000 1100
c = a | b;        # 61 = 0011 1101 
c = a ^ b;        # 49 = 0011 0001
c = ~a;           # -61 = 1100 0011
c = a << 2;       # 240 = 1111 0000
c = a >> 2;       # 15 = 0000 1111

I'd like to be able to do all of the above operations in GAP, but I can't seem to find anything in the documentation.

Here is a link to the documentation: https://www.gap-system.org/Manuals/doc/ref/chap0.html

like image 639
Dan P. Avatar asked Jun 18 '26 00:06

Dan P.


1 Answers

No, no such operations are directly available. Depending on what you actually want to do, you could of course "emulate" them in various ways, but that won't be quite as efficient. For example, you use boolean lists (which are internally stored as bitstrings), or vectors in a vector space over GF(2).

like image 170
Max Horn Avatar answered Jun 21 '26 02:06

Max Horn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!