in reply to decimal to binary conversion need help

If that example was chosen because it is the biggest number you will be dealing with, then you could get away with wrapping this into a function:

my $n = 9007199254740991; my( $hi, $lo ) = ( int( $n / 2**32 ), $n % 2**32 ); printf "%b%032b\n", $hi, $lo; 11111111111111111111111111111111111111111111111111111 $n--; ( $hi, $lo ) = ( int( $n / 2**32 ), $n % 2**32 ); printf "%b%032b\n", $hi, $lo; 11111111111111111111111111111111111111111111111111110 $n+=2; ( $hi, $lo ) = ( int( $n / 2**32 ), $n % 2**32 ); printf "%b%032b\n", $hi, $lo; 100000000000000000000000000000000000000000000000000000

but if your numbers get much bigger than 253, then you'll need to take the hit of using one of the bigInt libraries.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.