in reply to Re: Re: Converting an array of bytes into a BigInt - speed considerations
in thread Converting an array of bytes into a BigInt - speed considerations

That's a bummer. However, it needn't be a total disaster. You can get both quotient and remainder, by making two calls on the same data. For example, band() seems to work just fine as follows, to get at the remainder of a division by 256:
use Math::BigInt; $a = new Math::BigInt(0xFE78A3); printf '%02X', $a->band(0xFF);
Result:
A3
This is with Math::BigInt version 1.64.

Update: Yeah, the real solution would be for you to go back to school. ;-)

Replies are listed 'Best First'.
Re: Re: Re: Re: Converting an array of bytes into a BigInt - speed considerations
by dempa (Friar) on Jan 23, 2003 at 17:35 UTC

    Yeah, well I solved it like this:

    sub bigint_to_bytearray { my $bigint = shift; my @bytes; while(1) { push(@bytes,($bigint & 255)); $bigint->brsft(8); last if $bigint == 0; } return @bytes; }

    -- 
    dempa