Hi,
Running Cygwin perl 5.8.7 on Windows XP (32 bit).
Perl was built with -Duse64bitint.

-------------------
use warnings;
use Inline C => Config =>
   BUILD_NOISY => 1;

use Inline C => <<'EOC';

int foo(SV * integer) {

    if(SvIOK(integer)) {
      printf("IV: %s\n", SvPV_nolen(integer));
      return 1;
      }

    if(SvNOK(integer)) {
      printf("NV: %s\n", SvPV_nolen(integer));
      return 2;
      }

    printf("Neither IV nor NV");
    return 3;
}

EOC

{
use integer;
$x = 2 ** 57 + 12345;
}

$y = 2 ** 57 + 12345;

foo($x);
foo($y);
-------------------

This outputs:
IV: 144115188075868217
NV: 1.44115188075868e+17

foo() has no problem in getting $x into the string form "144115188075868217". But how can the same be achieved when foo() is given $y ?

I need to pass the value to the GMP C library. That library is not built with "long long" or "long double" support. The only way I can see of passing such large integer values successfully is to first convert them into a string of digits (as per what the foo function does to $x). But can that be achieved if the large integer argument is an NV ?

Cheers,
Rob

Reply via email to