packing and unpacking problem

Discussion in 'Perl' started by rag84dec, Sep 28, 2007.

  1. rag84dec

    rag84dec New Member

    Joined:
    Jul 17, 2007
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    0
    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");
     
  2. ungalnanban

    ungalnanban New Member

    Joined:
    Feb 19, 2010
    Messages:
    45
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Chennai
    I workout with your program but its not giving constant output.

    each time it giving different output.
     
  3. ungalnanban

    ungalnanban New Member

    Joined:
    Feb 19, 2010
    Messages:
    45
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Chennai
    Code:
    [COLOR=Navy] use bigint;
    
    my $r = 0x234;
    my $t = 0x345;
    
    my $x1 = $r << 32 | $t;
    
    print $x1->as_hex;    ### [COLOR=Red] 0x23400000345[/COLOR][/COLOR]   
    
    
    You can use the above code.
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice