Beispiel #1
0
 /*
  * @@ lua_numbertointeger converts a float number to an integer, or
  ** returns 0 if float is not within the range of a lua_Integer.
  ** (The range comparisons are tricky because of rounding. The tests
  ** here assume a two-complement representation, where MININTEGER always
  ** has an exact representation as a float; MAXINTEGER may not have one,
  ** and therefore its conversion to float may have an ill-defined value.)
  */
 public static bool lua_numbertointeger(LUA_NUMBER n, out LUA_INTEGER p)
 {
     //#define lua_numbertointeger(n,p) \
     //  ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
     //   (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
     //      (*(p) = (LUA_INTEGER)(n), 1))
     if ((n >= (LUA_NUMBER)(LUA_MININTEGER)) && (n < -(LUA_NUMBER)(LUA_MININTEGER)))
     {
         p = (LUA_INTEGER)n;
         return(true);
     }
     else
     {
         p = 0;
         return(false);
     }
 }
Beispiel #2
0
 public static String lua_integer2str(LUA_INTEGER n)
 {
     return(n.ToString(LUA_INTEGER_FMT_NET, CultureInfo.InvariantCulture));
 }
Beispiel #3
0
 public static int lua_integer2str(out String s, LUA_INTEGER n)
 {
     s = n.ToString(LUA_INTEGER_FMT_NET, CultureInfo.InvariantCulture);
     return(s.Length);
 }