#!/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?
int auses probably 32-bit representation. You should use unsigned intit if you want to represent values above 4,294,967,296/2.
int a
unsigned int
Perl , , , IV ( SV). newSVuv. UV a = unsigned a = int, ints - 32 , perl 64- , UV, newSVuv, 32 .
UV a =
unsigned a =