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

Поиск
Список
Период
Сортировка
От Salvador Fandiño
Тема Re: Perl's newSViv() versus 64-bit ints?
Дата
Msg-id 56E442A7.3030701@gmail.com
обсуждение исходный текст
Ответ на Re: 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 04:47 PM, Tom Lane wrote:
> Salvador Fandiño <sfandino@gmail.com> writes:
>> 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?).
>
> [ looks... ]  Oh, NV is a "double", which I think would be a perfectly
> reasonable choice: it'd be exact up to about 2^53, on most machines,
> which should be plenty for a long time to come.
>
> How much of a user-visible change would that be, if the "processed"
> field of a spi_exec_query() result started coming back as an NV not
> an IV?  I'm not sure how much that would affect semantics in typical
> Perl code.

At the Perl level, IVs and NVs are mostly indistinguishable, and Perl 
does promote values internally from IVs to NVs to avoid overflows 
automatically.

There are some operations that cause an implicit coercion from NV to IV 
(or UV) under the hood, and in those cases, big values would get 
mangled. For instance, bit operations as <<, >> or ~, or calling pack or 
printf with some integer template do that.

Those don't look like common operations for "processed".






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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Performance improvement for joins where outer side is unique