#!/usr/bin/env perl
use warnings;
use 5.012;
use Inline 'C';
my $value = test();
say $value;
__END__
__C__
void test() {
int a = 4294967294;
Inline_Stack_Vars;
Inline_Stack_Reset;
Inline_Stack_Push( sv_2mortal( newSViv( a ) ) );
Inline_Stack_Done;
}
Output:
-2
Why do I get here an output of “-2”?
int auses probably 32-bit representation. You should useunsigned intif you want to represent values above 4,294,967,296/2.