zsh-users
 help / color / mirror / code / Atom feed
* logical NOT
@ 2012-05-10 11:59 Mark van Dijk
  2012-05-10 12:30 ` René Neumann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mark van Dijk @ 2012-05-10 11:59 UTC (permalink / raw)
  To: zsh-users

Before I explain what I need let me explain why I need it.

Just now I was reading about MAC addresses, their binary
representation, and how MAC addresses are transmitted across a network.
This document mentions the address AC:DE:48:00:00:00. Converting that
to binary is easy:

for i (${(s.:.):-AC:DE:48:00:00:80}) echo $(( [#2] hex=0x$i ))

Here we can see 0xAC == 2#10101100.

From what I understand this is transmitted over a network from right to
left, so the receiver will receive 00110101 in that order. In this
sequence the first transmitted bit represents the individual/group
address bit and the second one represents the universally/locally
administered address bit, the reason for me reading this.

Then I wondered about how to let zsh "reverse" a binary number and came
up with the logical NOT: simply flip each bit. I've tried a lot of ways
but they all fail. What confuses me most is this:

% echo $(( [#2] ~0xAC ))
-2#10101101

I'd appreciate thoughts on this, and to hear if it makes any sense at
all :)

Thanks,
Mark.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-05-12 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 11:59 logical NOT Mark van Dijk
2012-05-10 12:30 ` René Neumann
2012-05-10 12:47 ` Jérémie Roquet
2012-05-10 15:12 ` Bart Schaefer
2012-05-10 18:02   ` Mikael Magnusson
2012-05-12 11:41     ` Internecto List Subscriber
2012-05-12 11:43     ` Mark

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).