On Thu, 26 Jul 2007, Shmuel Fomberg wrote:

>
>> From: Yona Shlomo [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, July 26, 2007 3:43 PM
>
>> 3. pack the number into a C long long int data type (i.e., a
>> 64 bite representation).
>
> You can always take the stringy path, that is: (tested)
> $x = Math::BigInt->new('123456789123');
> $str = $x->as_bin();
> substr($str, 0, 2) = '0' x (64 - length($str) + 2);
> $binary = pack "B*", $str;
>
> just make sure that you have the right byte order.
> (big/little indeans and so)

Can you explain the operations?

I looks like you're padding with '0' characters the binary
representation in string format of the big number -- but I
don't understand the purpose of the
    substr($str, 0, 2) = '0' x (64 - length($str) + 2);
neither the lvalue nor the rvalue

Thanks

-- 
Shlomo Yona
[EMAIL PROTECTED]
http://yeda.cs.technion.ac.il/~yona/
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to