Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: logical NOT



Hi,

2012/5/10 Mark van Dijk <lists+zsh@xxxxxxxxxxxxxx>:
> % echo $(( [#2] ~0xAC ))
> -2#10101101
>
> I'd appreciate thoughts on this, and to hear if it makes any sense at
> all :)

16#0xAC = 2#10101100
~16#0xAC = ~2#00000000000000000000000010101100 (this is not “logical
not”, btw, it's “one's complement”)
~16#0xAC = 2#11111111111111111111111101010011
which is a *signed* negative number of value 2#10101101 (see
https://en.wikipedia.org/wiki/Two's_complement)
~16#0xAC = -2#10101101

Makes sense for me… the complement is not limited to the most
significant set bit and the bits on its right, and these are signed
numbers.

Best regards,

-- 
Jérémie



Messages sorted by: Reverse Date, Date, Thread, Author