On 03/12/2016 12:49 AM, Tom Lane wrote:
> Anybody know what will happen when passing a uint64 to newSViv()?
On 64 bit platforms, it is just interpreted as a signed integer, any
number with the upper bit set will become negative. Perl provides
newSVuv for unsigned numbers.
On 32bit platforms and Perls compiled with 32 bit IVs the number is
truncated. My module Math::Int64 can be used to add support for 64bit
numbers there. It has a C API[*] which allows calling it from C code
easily. Another possibility is to just use newSVnv(), but NVs are not
able to represent all the uint64 range precisely (IIRC, they can
represent integers up to 48bits?).
Well, and then you can always use some bigint module, but AFAIK, the
ones distributed in the Perl core do not provide a C API.
* https://metacpan.org/pod/Math::Int64#C-API