aboutsummaryrefslogtreecommitdiff
path: root/src/lj_vmmath.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_vmmath.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c
index 623a686d..9ed37bf2 100644
--- a/src/lj_vmmath.c
+++ b/src/lj_vmmath.c
@@ -60,7 +60,8 @@ double lj_vm_foldarith(double x, double y, int op)
60int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) 60int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
61{ 61{
62 uint32_t y, ua, ub; 62 uint32_t y, ua, ub;
63 lua_assert(b != 0); /* This must be checked before using this function. */ 63 /* This must be checked before using this function. */
64 lj_assertX(b != 0, "modulo with zero divisor");
64 ua = a < 0 ? (uint32_t)-a : (uint32_t)a; 65 ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
65 ub = b < 0 ? (uint32_t)-b : (uint32_t)b; 66 ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
66 y = ua % ub; 67 y = ua % ub;
@@ -84,7 +85,7 @@ double lj_vm_log2(double a)
84static double lj_vm_powui(double x, uint32_t k) 85static double lj_vm_powui(double x, uint32_t k)
85{ 86{
86 double y; 87 double y;
87 lua_assert(k != 0); 88 lj_assertX(k != 0, "pow with zero exponent");
88 for (; (k & 1) == 0; k >>= 1) x *= x; 89 for (; (k & 1) == 0; k >>= 1) x *= x;
89 y = x; 90 y = x;
90 if ((k >>= 1) != 0) { 91 if ((k >>= 1) != 0) {
@@ -123,7 +124,7 @@ double lj_vm_foldfpm(double x, int fpm)
123 case IRFPM_SQRT: return sqrt(x); 124 case IRFPM_SQRT: return sqrt(x);
124 case IRFPM_LOG: return log(x); 125 case IRFPM_LOG: return log(x);
125 case IRFPM_LOG2: return lj_vm_log2(x); 126 case IRFPM_LOG2: return lj_vm_log2(x);
126 default: lua_assert(0); 127 default: lj_assertX(0, "bad fpm %d", fpm);
127 } 128 }
128 return 0; 129 return 0;
129} 130}