Help for this page

Select Code to Download


  1. or download this
    use warnings;
    use strict;
    ...
    
    my $num = 1023; # 0x03ff
    my ($b1, $b2);
    
  2. or download this
    $b1 = ($num & 0xff00) >> 8;
    $b2 = $num & 0xff;
    
    printf("%x, %x\n", $b1, $b2); # 3, ff
    
  3. or download this
    $b1 = $num & 0xff;
    $b2 = ($num & 0xff00) >> 8;
    
    printf("%x, %x\n", $b1, $b2); # ff, 3
    
  4. or download this
    use warnings;
    use strict;
    ...
    $b2 = ($num & 0xff00) >> 8;
    
    printf("%x, %x\n", $b1, $b2);