in reply to dec to bin conversion for large numbers

How about a little DIY?

This is untested, but...

use POSIX qw(floor); sub dec2Bin($) { $n = shift; while ($n != 0) { $k = $n % 2; $n = floor($n / 2); $b = $k . $b; } print "$b"; }
chiller

Replies are listed 'Best First'.
Re: Re: dec to bin conversion for large numbers
by chiller (Scribe) on Sep 14, 2001 at 21:51 UTC
    yeah that doesn't work...

    So I have a more general question:

    Anything >= 2^11 (or so) results in perl printing "inf"? Is there a way to force a "long" primitive, or what?