summaryrefslogtreecommitdiff
path: root/Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c')
-rw-r--r--Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c b/Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c
index ab84fda76d2..9271f68a117 100644
--- a/Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c
+++ b/Build/source/libs/luajit/LuaJIT-src/src/lj_strfmt_num.c
@@ -1,6 +1,6 @@
/*
** String formatting for floating-point numbers.
-** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
+** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** Contributed by Peter Cawley.
*/
@@ -138,7 +138,7 @@ static uint32_t nd_mul2k(uint32_t* nd, uint32_t ndhi, uint32_t k,
}
if (carry_in) {
nd[++ndhi] = carry_in; carry_in = 0;
- if(start++ == ndlo) ++ndlo;
+ if (start++ == ndlo) ++ndlo;
}
k -= ND_MUL2K_MAX_SHIFT;
}
@@ -364,6 +364,7 @@ static char *lj_strfmt_wfnum(SBuf *sb, SFormat sf, lua_Number n, char *p)
/* Precision is sufficiently low that rescaling will probably work. */
if ((ndebias = rescale_e[e >> 6])) {
t.n = n * rescale_n[e >> 6];
+ if (LJ_UNLIKELY(!e)) t.n *= 1e10, ndebias -= 10;
t.u64 -= 2; /* Convert 2ulp below (later we convert 2ulp above). */
nd[0] = 0x100000 | (t.u32.hi & 0xfffff);
e = ((t.u32.hi >> 20) & 0x7ff) - 1075 - (ND_MUL2K_MAX_SHIFT < 29);
@@ -479,7 +480,7 @@ static char *lj_strfmt_wfnum(SBuf *sb, SFormat sf, lua_Number n, char *p)
if ((prec | (sf & STRFMT_F_ALT))) {
/* Emit fractional part. */
p[1] = '.'; p += 2;
- prec -= (q - p); p = q; /* Account for the digits already emitted. */
+ prec -= (MSize)(q - p); p = q; /* Account for digits already emitted. */
/* Then emit chunks of 9 digits (this may emit 8 digits too many). */
for (i = ndhi; (int32_t)prec > 0 && i != ndlo; prec -= 9) {
i = (i - 1) & 0x3f;