diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-02-05 15:15:33 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-02-05 15:15:33 -0200 |
commit | c8d6cb01365780367f949a94b29bb3f043744c0e (patch) | |
tree | 7a70fb480a12b656771efcea82ea07ac9c863d3a /luaconf.h | |
parent | 0edcdf49c00b70986f3efc12ceae912db2361d67 (diff) | |
download | lua-c8d6cb01365780367f949a94b29bb3f043744c0e.tar.gz lua-c8d6cb01365780367f949a94b29bb3f043744c0e.tar.bz2 lua-c8d6cb01365780367f949a94b29bb3f043744c0e.zip |
macros 'luai_num*' (for float arithmetic operations) moved to
llimits.h.
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 42 |
1 files changed, 1 insertions, 41 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.243 2015/02/04 12:52:57 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.244 2015/02/05 16:53:34 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 | */ |
@@ -466,46 +466,6 @@ | |||
466 | (*(p) = (LUA_INTEGER)(n), 1)) | 466 | (*(p) = (LUA_INTEGER)(n), 1)) |
467 | 467 | ||
468 | 468 | ||
469 | /* | ||
470 | @@ The luai_num* macros define the primitive operations over numbers. | ||
471 | ** They should work for any size of floating numbers. | ||
472 | */ | ||
473 | |||
474 | /* the following operations need the math library */ | ||
475 | #if defined(lobject_c) || defined(lvm_c) | ||
476 | #include <math.h> | ||
477 | |||
478 | /* floor division (defined as 'floor(a/b)') */ | ||
479 | #define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) | ||
480 | |||
481 | /* | ||
482 | ** module: defined as 'a - floor(a/b)*b'; the previous definition gives | ||
483 | ** NaN when 'b' is huge, but the result should be 'a'. 'fmod' gives the | ||
484 | ** result of 'a - trunc(a/b)*b', and therefore must be corrected when | ||
485 | ** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a | ||
486 | ** non-integer negative result, which is equivalent to the test below | ||
487 | */ | ||
488 | #define luai_nummod(L,a,b,m) \ | ||
489 | { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } | ||
490 | |||
491 | /* exponentiation */ | ||
492 | #define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) | ||
493 | |||
494 | #endif | ||
495 | |||
496 | /* these are quite standard operations */ | ||
497 | #if defined(LUA_CORE) | ||
498 | #define luai_numadd(L,a,b) ((a)+(b)) | ||
499 | #define luai_numsub(L,a,b) ((a)-(b)) | ||
500 | #define luai_nummul(L,a,b) ((a)*(b)) | ||
501 | #define luai_numdiv(L,a,b) ((a)/(b)) | ||
502 | #define luai_numunm(L,a) (-(a)) | ||
503 | #define luai_numeq(a,b) ((a)==(b)) | ||
504 | #define luai_numlt(a,b) ((a)<(b)) | ||
505 | #define luai_numle(a,b) ((a)<=(b)) | ||
506 | #define luai_numisnan(a) (!luai_numeq((a), (a))) | ||
507 | #endif | ||
508 | |||
509 | 469 | ||
510 | /* | 470 | /* |
511 | @@ LUA_INTEGER is the integer type used by Lua. | 471 | @@ LUA_INTEGER is the integer type used by Lua. |