[tarantool-patches] Re: [PATCH v1 1/1] lua: fix strange behaviour of tonumber64
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Jul 18 00:48:25 MSK 2018
Thanks for the fixes! I have fixed the commit
message on the branch. Now the patch LGTM.
On 17/07/2018 15:03, Kirill Shcherbatov wrote:
>>>> +-- gh-3466: Strange behaviour of tonumber64 function
>>>> +--
>>>> +tostring(tonumber64('18446744073709551615')) == '18446744073709551615ULL'
>>>> +tonumber64('18446744073709551616') == nil
>>> 2. Where is a test for another corner case? I mean INT64_MAX.
> Actually, the max value is not INT64_MAX; but UINT64_MAX that is tested above.
> But I don't mind to add INT64_MAX test.
> +tostring(tonumber64('9223372036854775807')) == '9223372036854775807ULL'
>
>> I also propose to test zero.
> +tostring(tonumber64('0')) == '0'
>
>> 1. Please, add a comment about the things we have discussed as Alexander asked
>> in the previous message.
> + /*
> + * To test overflow, consider
> + * result > -INT64_MIN;
> + * result - 1 > -INT64_MIN - 1;
> + * Assumption:
> + * INT64_MAX == -(INT64_MIN + 1);
> + * Finally,
> + * result - 1 > INT64_MAX;
> + */
>
More information about the Tarantool-patches
mailing list