Re: Perl's newSViv() versus 64-bit ints?

Поиск
Список
Период
Сортировка
От Salvador Fandiño
Тема Re: Perl's newSViv() versus 64-bit ints?
Дата
Msg-id 56E3C3B6.7010607@gmail.com
обсуждение исходный текст
Ответ на Perl's newSViv() versus 64-bit ints?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Perl's newSViv() versus 64-bit ints?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.


* https://metacpan.org/pod/Math::Int64#C-API



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Kuleshov
Дата:
Сообщение: [PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned()
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Provide much better wait information in pg_stat_activity.