in reply to split 64 bit number

It is unfortunate that Perl does not have native 64-bit support (i.e. "long long"), as many compilers are adding this.

That being said, what you are doing is functional, but since the Math::BigInt library does not appear to be optimized that well, it will be slow. This may be because the library is intended to work on very big numbers, much larger than 64 bit.

If speed were an issue, a quick bit of Inline::C would certainly help.

Replies are listed 'Best First'.
Re: Re: split 64 bit number
by wog (Curate) on Aug 11, 2001 at 03:56 UTC
    That perl does not have "native 64-bit support" is not entirely true. Perl has this support, but it is a compile-time option, and is usually not enabled. But when this support is enabled this task can be done with:

    my $num = 10531788168169408; my($l,$r) = ($n>>32 & 0xFfffFfff, $n & 0xFfffFfff);

    You can tell if perl is compiled with 64-bit integer support with perl -v. It will say something like:

    This is perl, vX.Y.Z built for i686-linux-64int-ld
    

    or maybe:

    This is perl, vX.Y.Z built for sun4-solaris-thread-64all
    

    (Of course the part that's emphasized is all that's important there.)