|
Posted by jammer on March 18, 2008, 10:20 am
Please log in for more thread options On Mar 18, 5:29 am, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
> jammer wrote:
>
> >>> I have a hex number which is actually a MAC address and I want to find
> >>> the MAC immediately before.
> >>> 0000AAAA9999
> >>> Is there a way to treat it as a hex number and do -1 one on it?
> >> my $MAC = '0000AAAA9999';
> >> printf "%x\n", hex($MAC) - 1;
>
> >> Ben
>
> > What if there are not 4 leading 0s.
> > my $MAC = '000BAAAA9999';
> > printf "%x\n", hex($MAC) - 1;
> > Integer overflow in hexadecimal number
>
> Pragmatic approach: split up into smaller parts, do the math, then
> re-assemble.
>
Good idea. :-)
|