[tarantool-patches] Re: [PATCH v1 1/1] lua: fix strange behaviour of tonumber64

  • From: Vladislav Shpilevoy <v.shpilevoy@xxxxxxxxxxxxx>
  • To: Kirill Shcherbatov <kshcherbatov@xxxxxxxxxxxxx>, tarantool-patches@xxxxxxxxxxxxx, Alexander Turenko <alexander.turenko@xxxxxxxxxxxxx>
  • Date: Wed, 18 Jul 2018 00:48:25 +0300

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;
+                                */


Other related posts: