** next function does not use 'modf', avoiding problems with 'double*' ** (which is not compatible with 'float*') when lua_Number is not ** 'double'. */
| 137 | ** 'double'. |
| 138 | */ |
| 139 | static int math_modf (lua_State *L) { |
| 140 | if (lua_isinteger(L ,1)) { |
| 141 | lua_settop(L, 1); /* number is its own integer part */ |
| 142 | lua_pushnumber(L, 0); /* no fractional part */ |
| 143 | } |
| 144 | else { |
| 145 | lua_Number n = luaL_checknumber(L, 1); |
| 146 | /* integer part (rounds toward zero) */ |
| 147 | lua_Number ip = (n < 0) ? l_mathop(ceil)(n) : l_mathop(floor)(n); |
| 148 | pushnumint(L, ip); |
| 149 | /* fractional part (test needed for inf/-inf) */ |
| 150 | lua_pushnumber(L, (n == ip) ? l_mathop(0.0) : (n - ip)); |
| 151 | } |
| 152 | return 2; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | static int math_sqrt (lua_State *L) { |
nothing calls this directly
no test coverage detected