Click here to get back home

decrease MAC

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
decrease MAC jammer 03-17-2008
Posted by Jürgen Exner on March 17, 2008, 7:57 pm
Please log in for more thread options
>> > 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;
>
>What if there are not 4 leading 0s.

So what? Doesn't matter.

>my $MAC = '000BAAAA9999';
>printf "%x\n", hex($MAC) - 1;
>Integer overflow in hexadecimal number

That error message simply indicates that the numerical value exceeds the
largest possible number in this version of the perl interpreter.
What is the output of 'perl -V' on your system?

Maybe the bigint module will help on systems with a low maxint, but that is
just a guess.

jue

Posted by Josef Moellers on March 18, 2008, 5:29 am
Please log in for more thread options
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.

--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

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. :-)

Posted by Lawrence Statton on March 18, 2008, 2:10 pm
Please log in for more thread options
> >
> > Pragmatic approach: split up into smaller parts, do the math, then
> > re-assemble.
> >
> Good idea. :-)

Especially when you consider that a MAC is made up of two sections of
3-octets each (a 3-octet mfr block ID and a 3-octet part assigned by
that mfr), such that a borrow across that border makes no sense ...

--
        Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
place them into the correct order.

Posted by Jürgen Exner on March 17, 2008, 7:33 pm
Please log in for more thread options
>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?

"God made the natural numbers, all else is men's work"
There is no such thing as a hex(adezimal) number. You got numbers and that
is what Perl knows about and where you can add and subtract and do other
fancy stuff with.

And then you can input as well as print those numbers in different
representations, e.g. as a hexadecimal representation of a number.
- to convert the hex representation of a number into a number use hex()
- to print the hexadezimal representation of a number use printf

jue

Similar ThreadsPosted
deleteing records from DB_File doesnt decrease file size? September 15, 2006, 7:31 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap