Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
logical NOT
- X-seq: zsh-users 17071
- From: Mark van Dijk <lists+zsh@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: logical NOT
- Date: Thu, 10 May 2012 13:59:34 +0200
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Internecto SIS
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author