lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


This code is hereby released into the public domain.

lua_Number ipow(lua_Number a, lua_Number k) {
  if (k < 0) return 0;
  else {
    lua_Number b = 1;
    for (b = k & 1 ? a : 1, k >>= 1; k; k >>= 1) {
      a *= a;
      if (k & 1) b *= a;
    }
    return b;
  }
}