develooper Front page | perl.beginners | Postings from April 2012

Re: Question on the function - hex

Thread Previous | Thread Next
From:
Shawn H Corey
Date:
April 12, 2012 13:43
Subject:
Re: Question on the function - hex
Message ID:
4F873E7C.1010509@gmail.com
On 12-04-12 04:34 PM, Parag Kalra wrote:
> Why does the output of
> perl -e "print hex '0x00001600000402'"
>
> differs from the output of
> perl -e "print hex 0x00001600000402"
>
> EG:
> bash-3.2$ perl -e "print hex '0x00001600000402'"
> 94489281538
>
> $ perl -e "print hex 0x00001600000402"
> 10189963531576
>

$ perl -e "print hex '0x16'"
22
$ perl -e "print hex 0x16"
34
$ perl -e "print hex '22'"
34

When inside quotes, '0x16' is interpreted by hex to be a hex string and 
convert to 22. When outside, perl interprets 0x16 as 22 which is passed 
to hex to produce 34.


-- 
Just my 0.00000002 million dollars worth,
   Shawn

Programming is as much about organization and communication
as it is about coding.

[updated for today's programmers]
"Show me your code and conceal your interfaces, and I shall continue
to be mystified. Show me your interfaces, and I won't usually need
your code; it'll be obvious."
	-- Fred Brooks

Don't be clever; being great is good enough.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About