"Inline C" - request

#!/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;
}

Conclusion:

-2

Why am I getting the result "-2" here?

+5
source share
2 answers

int auses probably 32-bit representation. You should use unsigned intit if you want to represent values ​​above 4,294,967,296/2.

+5
source

Perl , , , IV ( SV). newSVuv. UV a = unsigned a = int, ints - 32 , perl 64- , UV, newSVuv, 32 .

+5

All Articles