#!/usr/bin/perl
# Idiom #84 Count bits set in integer binary representation
# https://p...content-available-to-author-only...s.org/idiom/84/count-bits-set-in-integer-binary-representation

@values = (
    19,
    2**31 - 1, 
    0b0111101000110001,
    0xA1,
    0xA3,
);

foreach my $i ( @values ) {
    $b = pack 'i', $i;
    $c = unpack '%b*', $b;
    printf "hex %X dec %d bin %b has %d bits\n", $i, $i, $i, $c;    
}
