aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-26 14:10:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-26 14:10:22 -0300
commitc98f195eb930422be2829f78696fb4bf79b93677 (patch)
tree119b0eca4b1b1435f6a73cecb50e368455081c14 /luaconf.h
parent4d696c45b9710e4b3d2eb65a0ebef79766937a4a (diff)
downloadlua-c98f195eb930422be2829f78696fb4bf79b93677.tar.gz
lua-c98f195eb930422be2829f78696fb4bf79b93677.tar.bz2
lua-c98f195eb930422be2829f78696fb4bf79b93677.zip
function 'luaV_numtointeger' changed to a global macro
'lua_numtointeger' (tricky, small, and useful in several places)
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/luaconf.h b/luaconf.h
index 40bb5ef5..bb2b776b 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.202 2014/05/15 15:24:32 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.203 2014/05/21 15:24:21 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*/
@@ -506,6 +506,24 @@
506 506
507 507
508/* 508/*
509@@ lua_numtointeger converts a float number to an integer, or
510** return 0 if float is not within the range of a lua_Integer.
511** (The comparisons are tricky because of rounding, which can or
512** not occur depending on the relative sizes of floats and integers.
513** The tests here assume a two-complement representation, where
514** MININTEGER always has an exact representation as a float,
515** while if LUA_MAXINTEGER has an exact representation, so does
516** (LUA_MAXINTEGER + 1); otherwise, LUA_MAXINTEGER is equal to
517** (LUA_MAXINTEGER + 1) when converted to a float.)
518** This macro should be used only when 'n' has an integral value.
519*/
520#define lua_numtointeger(n,p) \
521 (((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
522 (n) < (LUA_NUMBER)(LUA_MAXINTEGER) + 1) && \
523 (*p = (LUA_INTEGER)(n), 1))
524
525
526/*
509@@ The luai_num* macros define the primitive operations over numbers. 527@@ The luai_num* macros define the primitive operations over numbers.
510** They should work for any size of floating numbers. 528** They should work for any size of floating numbers.
511*/ 529*/