Skip to content

Commit

Permalink
use round(), See issue #74
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Dec 29, 2017
1 parent 3093cd8 commit 54968d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lsproto.c
Expand Up @@ -2,6 +2,7 @@

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "msvcint.h"

#include "lua.h"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 54968d0

Please sign in to comment.