sproto bugfix

This commit is contained in:
Cloud Wu
2018-01-23 11:24:44 +08:00
parent bbf46f935a
commit 04f4004934
2 changed files with 33 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "msvcint.h"
#include "lua.h"
@@ -172,7 +173,7 @@ encode(const struct sproto_arg *args) {
// It's decimal.
lua_Number vn = lua_tonumber(L, -1);
// use 64bit integer for 32bit architecture.
v = (int64_t)(vn * args->extra + 0.5);
v = (int64_t)(round(vn * args->extra));
} else {
v = lua_tointegerx(L, -1, &isnum);
if(!isnum) {