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

  • From: Kirill Shcherbatov <kshcherbatov@xxxxxxxxxxxxx>
  • To: tarantool-patches@xxxxxxxxxxxxx, Vladislav Shpilevoy <v.shpilevoy@xxxxxxxxxxxxx>, Alexander Turenko <alexander.turenko@xxxxxxxxxxxxx>
  • Date: Tue, 17 Jul 2018 15:03:53 +0300

+-- 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: