in reply to Big Int to hex with 5.6

If you are using the Math::BigInt module call $x->as_hex(); as it says in the module documentation.

Replies are listed 'Best First'.
Re^2: Big Int to hex with 5.6
by ZlR (Chaplain) on Dec 12, 2004 at 20:39 UTC
    Well apparently not with win32 5.6 :

    #!perl use strict ; use warnings; my $bignum = Math::BigInt->new('1111111111111111111111111'); $bignum->as_hex(); print $bignum ;

    gives :

    Can't locate object method "new" via package "Math::BigInt" (perhaps y +ou forgot to load "Math::BigInt"?) at t.pl line 4.

    as_hex is not in the doc, either, but i indeed saw it with 5.8

      So you are using an older version of the module, you should upgrade the module if you want this functionality.
        no. it will run on a large number of machines and i have no possibility to upgrade them all, moreover for a single functionality.
      There's an important clue in the error message: you need to use Math::Bigint; (or use bigint;). But if you aren't already doing that, what do you mean by a "bigint number"?

      Oh, I see; you perhaps are using the ancient decrepit perl4-ish bigint.pl; you are strongly advised to install a new version of Math::BigInt (which I believe includes a bigint.pm module also) which has scads of bug fixes and use it instead.

      You also should be doing print $bignum->as_hex();; just calling it in void context doesn't do anything.

        you perhaps are using the ancient decrepit perl4-ish bigint.pl

        I'm using active perl 5.6, and as far as i understand it as_hex is not in the methods offered : BigInt ActiveState

        Sadly upgrading is not an option here. How can do it ? I'm trying to divide by 16 as in a standard conversion but it doesn't work very well ...

      err, sorry !

      Here it is :

      #!perl use strict ; use warnings; use Math::BigInt ; my $bignum = Math::BigInt->new('1111111111111111111111111'); $bignum->as_hex(); print $bignum ;
      gives
      Can't locate object method "as_hex" via package "Math::BigInt" (perhap +s you forgot to load "Math::BigInt"?) at t.pl line 6.