Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   packing and unpacking problem (http://www.go4expert.com/forums/packing-unpacking-t6585/)

rag84dec 28Sep2007 14:59

packing and unpacking problem
 
Hi,
I want to get output as 0x23400000345....in the below example
how to get??..i tried out the following but unable to get the anser ....

please help...


$r=0x234;
$t=0x345;

$y=pack('L L',$t,$r);
$x1=unpack('L!',pack('P',$y));
printf("\nThe value is $x1");

ungalnanban 25Feb2010 10:30

Re: packing and unpacking problem
 
I workout with your program but its not giving constant output.

each time it giving different output.

ungalnanban 15Mar2010 10:34

Re: packing and unpacking problem
 
Code:

use bigint;

my $r = 0x234;
my $t = 0x345;

my $x1 = $r << 32 | $t;

print $x1->as_hex;    ### 0x23400000345

You can use the above code.


All times are GMT +5.5. The time now is 05:34.