From: | Salvador Fandiño <sfandino(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Perl's newSViv() versus 64-bit ints? |
Date: | 2016-03-12 07:22:30 |
Message-ID: | 56E3C3B6.7010607@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2016-03-12 07:24:15 | Re: [COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity. |
Previous Message | Alexander Kuleshov | 2016-03-12 07:09:54 | [PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned() |