> > Not allowing bit_and(x,x) => x and bit_and(x,bit_not(x)) => 0 and
> > bit_or(x,bit_not(x)) => -1 without explicit declarations of x as an
> > integer would make using bit_xxx far more clumsy, and I'm not sure it
> > would prevent any real errors.
>
> Yeah, it's probably OK to allow such operations.
Robert,
according to this statement I propose the following specification of bit_and and bit_not.
If these two funcitions are defined, the other bit_xyz functions specifications are written
accordingly.
;; bitwise AND
;; ERROR if at least one arg to bit_and is a non-integer constant, string or Maxima list
bit_and() --> -1
bit_and(m,n) --> bitwise m AND n for any literal integer m,n
bit_and(m,n,x) --> bit_and(bit_and(m,n),x) for any literal integer m,n and any expression x
bit_and(x) --> x for any expression x (*)
bit_and(x,x,y) --> bit_and(x,y) for any expression x,y
bit_and(0,x) --> 0 for any expression x
bit_and(-1,x) --> bit_and(x) for any expression x
bit_and(x,bit_not(x),y) --> 0 for any expression x,y
bit_and(1,e,x,y,z,..) --> 0 for any declared even integer e and any expressions x,y,z,..
bit_and(1,o,p,q,..) --> 0 where all o,p,q,.. are declared as odd integers
bit_and(x,y) --> bit_and(x,y) for any other expression x,y
;; bitwise NOT
;; ERROR if arg to bit_not is a non-integer constant, string or Maxima list
bit_not(x) --> -x-1 for any other expression x (*)
(*) if more restricive versions are preferred, the following definitions can be used instead:
bit_and(x) --> x for any declared integer x or value of an integervalued function
bit_not(x) --> -x-1 for any declared integer x or value of an integervalued function
bit_not(x) --> bit_not(x) for any other expression x
Let me know what you think.
Best
Volker