hermann on Wed, 05 Jul 2023 20:56:55 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

How to do t_INT bit operations?


I found bit shift operators in users.pdf:

? 13 << 2
%37 = 52
? 13 >> 1
%38 = 6
?

And "digits()" and "fromdigits()".

? a=digits(13, 2)
%39 = [1, 1, 0, 1]
? a[2]=0
%40 = 0
? a
%41 = [1, 0, 0, 1]
? fromdigits(a, 2)
%42 = 9
?


Is that the way to do t_INT bit operations in GP?
Are there alternatives more like the C bit operators?


Regards,

Hermann.