negative decimal number

This commit is contained in:
Cloud Wu
2017-06-26 16:32:43 +08:00
parent 72b6039328
commit eb2bc91e3f
2 changed files with 3 additions and 3 deletions

View File

@@ -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.

View File

@@ -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;