aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/luaconf.h b/luaconf.h
index f9cd7283..bb6077c5 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.110 2009/09/28 16:32:50 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.111 2009/10/11 20:02:19 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -500,14 +500,20 @@
500/* 500/*
501@@ The luai_num* macros define the primitive operations over numbers. 501@@ The luai_num* macros define the primitive operations over numbers.
502*/ 502*/
503#if defined(LUA_CORE) 503
504/* the following operations need the math library */
505#if defined(lobject_c) || defined(lvm_c)
504#include <math.h> 506#include <math.h>
507#define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
508#define luai_numpow(L,a,b) (pow(a,b))
509#endif
510
511/* these are quite standard operations */
512#if defined(LUA_CORE)
505#define luai_numadd(L,a,b) ((a)+(b)) 513#define luai_numadd(L,a,b) ((a)+(b))
506#define luai_numsub(L,a,b) ((a)-(b)) 514#define luai_numsub(L,a,b) ((a)-(b))
507#define luai_nummul(L,a,b) ((a)*(b)) 515#define luai_nummul(L,a,b) ((a)*(b))
508#define luai_numdiv(L,a,b) ((a)/(b)) 516#define luai_numdiv(L,a,b) ((a)/(b))
509#define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
510#define luai_numpow(L,a,b) (pow(a,b))
511#define luai_numunm(L,a) (-(a)) 517#define luai_numunm(L,a) (-(a))
512#define luai_numeq(a,b) ((a)==(b)) 518#define luai_numeq(a,b) ((a)==(b))
513#define luai_numlt(L,a,b) ((a)<(b)) 519#define luai_numlt(L,a,b) ((a)<(b))
@@ -516,6 +522,7 @@
516#endif 522#endif
517 523
518 524
525
519/* 526/*
520@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. 527@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
521** CHANGE that if ptrdiff_t is not adequate on your machine. (On most 528** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
@@ -574,6 +581,25 @@ union luai_Cast { double l_d; long l_l; };
574#define lua_uint2number(u) \ 581#define lua_uint2number(u) \
575 ((LUA_INT32)(u) < 0 ? (lua_Number)(u) : (lua_Number)(LUA_INT32)(u)) 582 ((LUA_INT32)(u) < 0 ? (lua_Number)(u) : (lua_Number)(LUA_INT32)(u))
576 583
584
585/*
586@@ luai_hashnum is a macro do hash a lua_Number value into an integer.
587@* The hash must be deterministic and give reasonable values for
588@* both small and large values (outside the range of integers).
589@* It is used only in ltable.c.
590*/
591
592#if defined(ltable_c)
593
594#include <float.h>
595#include <math.h>
596
597#define luai_hashnum(i,d) { int e; \
598 d = frexp(d, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \
599 lua_number2int(i, d); i += e; }
600
601#endif
602
577/* }================================================================== */ 603/* }================================================================== */
578 604
579 605