From eb2bc91e3fbf273e97e5f8f63f3d4154dd269e05 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 26 Jun 2017 16:32:43 +0800 Subject: [PATCH] negative decimal number --- lualib-src/sproto/README.md | 2 +- lualib-src/sproto/lsproto.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lualib-src/sproto/README.md b/lualib-src/sproto/README.md index 9fd4c3ff..237e4b5c 100644 --- a/lualib-src/sproto/README.md +++ b/lualib-src/sproto/README.md @@ -252,7 +252,7 @@ If n is odd, that means the tags is not continuous, and we should add current ta Arrays are always encode in data part, 4 bytes header for the size, and the following bytes is the contents. See the example 2 for the struct array; example 3/4 for the integer array ; example 5 for the boolean array. -Fot integer array, an additional byte (4 or 8) to indicate the value is 32bit or 64bit. +For integer array, an additional byte (4 or 8) to indicate the value is 32bit or 64bit. Read the examples below to see more details. diff --git a/lualib-src/sproto/lsproto.c b/lualib-src/sproto/lsproto.c index d7160a62..9cb61a4a 100644 --- a/lualib-src/sproto/lsproto.c +++ b/lualib-src/sproto/lsproto.c @@ -344,12 +344,12 @@ decode(const struct sproto_arg *args) { // notice: in lua 5.2, 52bit integer support (not 64) if (args->extra) { // lua_Integer is 32bit in small lua. - uint64_t v = *(uint64_t*)args->value; + int64_t v = *(int64_t*)args->value; lua_Number vn = (lua_Number)v; vn /= args->extra; lua_pushnumber(L, vn); } else { - lua_Integer v = *(uint64_t*)args->value; + lua_Integer v = *(int64_t*)args->value; lua_pushinteger(L, v); } break;