Hi,

I have an array of large integers, each integer being no larger than 1e14 -
1. I want to pass these integers to inline, perform an operation on them,and
then return the final values to perl. The returned values can also be a
maximum 1e14 - 1.

To this end, I've tried the following script:
----start--------------------------------------------
#!perl -w

use Inline C => <<'END_OF_C_CODE';

void dumb ( SV* a, ...) {

Inline_Stack_Vars;
double tt;
int i;

Inline_Stack_Reset;

for (i = 0; i < 4; ++i) {
tt = SvIV(Inline_Stack_Item(i));
if (i == 3) tt *= 10;
printf("%f ", tt);
Inline_Stack_Push(newSViv(tt));
}

Inline_Stack_Done;
Inline_Stack_Return(4);

}

END_OF_C_CODE

my @num = (99999999999999, 2147483648,
          2147483647,2147483646);

my @ret = dumb(@num);
print "\n@ret\n";
---finish---------------------------------------------

The printf statements output:
-1.000000
-2147483648.000000
2147483647.000000
21474836460.000000
which reveals that some integers are not being passed to inline as desired.

Printing @ret outputs:
-1
-2147483648
2147483647
-20
which reveals that the returned values don't necessarily match the value
that 'tt' holds.

I've tried changing the type of  'tt' to 'long double', 'float', 'unsigned
long int', 'long int' and even 'unsigned int'......... without success.

Is there some 'type' that I've missed ? Or, perhaps, I'm simply barking up
the wrong tree ?

I'm on Win2k, MSVC++ 6.0, Inline 0.43 and perl 5.6.1.

Cheers,
Rob

Reply via email to