print a number in hex
am 07.10.2007 14:31:32 von AmirHi,
I have a variable let's say $address, I would like to print it , but
in its Hex value and not Decimal, how can I do it?
thanks a lot !
-Amir
Hi,
I have a variable let's say $address, I would like to print it , but
in its Hex value and not Decimal, how can I do it?
thanks a lot !
-Amir
Amir wrote:
> Hi,
> I have a variable let's say $address, I would like to print it , but
> in its Hex value and not Decimal, how can I do it?
printf and sprintf are your friends.
On Oct 7, 8:31 am, Amir
> I have a variable let's say $address, I would like to print it ,
> but in its Hex value and not Decimal, how can I do it?
Use printf() (or sprintf()), using either the %x or %X format
specifier:
$ perl -e'printf("%X\n", 30)'
1E
Paul Lalli
On Oct 7, 5:15 pm, Paul Lalli
> On Oct 7, 8:31 am, Amir
>
> > I have a variable let's say $address, I would like to print it ,
> > but in its Hex value and not Decimal, how can I do it?
>
> Use printf() (or sprintf()), using either the %x or %X format
> specifier:
>
> $ perl -e'printf("%X\n", 30)'
> 1E
>
> Paul Lalli
thanks guys,
I have one more question,
I have this code:
$address = ($address & zero_bits(3,11)) | (($col<<3) & 0xff8);
now, the function zero_bits returns a hex number, but it seems that
perl considers it as a decimal, and calculates wrongly the bitwise.
what should I do?!
thanks again
-Amir
On Oct 7, 1:51 pm, Amir
> I have this code:
> $address = ($address & zero_bits(3,11)) | (($col<<3) & 0xff8);
> now, the function zero_bits returns a hex number,
No. Perl does not return hex nor decimal. It returns numbers.
"hex" and "decimal" and "octal" are simply ways of displaying
representations of numbers.
> but it seems that
> perl considers it as a decimal, and calculates wrongly the bitwise.
> what should I do?!
You should do what the Posting Guidelines tell you to do - create a
short-but-complete script that demonstrates your problem, and post
that.
Paul Lalli
On Sun, 07 Oct 2007 17:51:02 -0000, Amir
>I have one more question,
Then you'd better start a new thread...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^