jsmath.c expanded

This commit is contained in:
Tor Andersson
2014-01-21 14:14:51 +01:00
parent 3a92e13e47
commit ca79fc1497
+79 -32
View File
@@ -2,53 +2,100 @@
#include "jsvalue.h"
#include "jsbuiltin.h"
static int Math_abs(js_State *J, int argc) {
return js_pushnumber(J, abs(js_tonumber(J, 1))), 1;
static int Math_abs(js_State *J, int argc)
{
js_pushnumber(J, abs(js_tonumber(J, 1)));
return 1;
}
static int Math_acos(js_State *J, int argc) {
return js_pushnumber(J, acos(js_tonumber(J, 1))), 1;
static int Math_acos(js_State *J, int argc)
{
js_pushnumber(J, acos(js_tonumber(J, 1)));
return 1;
}
static int Math_asin(js_State *J, int argc) {
return js_pushnumber(J, asin(js_tonumber(J, 1))), 1;
static int Math_asin(js_State *J, int argc)
{
js_pushnumber(J, asin(js_tonumber(J, 1)));
return 1;
}
static int Math_atan(js_State *J, int argc) {
return js_pushnumber(J, atan(js_tonumber(J, 1))), 1;
static int Math_atan(js_State *J, int argc)
{
js_pushnumber(J, atan(js_tonumber(J, 1)));
return 1;
}
static int Math_atan2(js_State *J, int argc) {
return js_pushnumber(J, atan2(js_tonumber(J, 1), js_tonumber(J, 2))), 1;
static int Math_atan2(js_State *J, int argc)
{
js_pushnumber(J, atan2(js_tonumber(J, 1), js_tonumber(J, 2)));
return 1;
}
static int Math_ceil(js_State *J, int argc) {
return js_pushnumber(J, ceil(js_tonumber(J, 1))), 1;
static int Math_ceil(js_State *J, int argc)
{
js_pushnumber(J, ceil(js_tonumber(J, 1)));
return 1;
}
static int Math_cos(js_State *J, int argc) {
return js_pushnumber(J, cos(js_tonumber(J, 1))), 1;
static int Math_cos(js_State *J, int argc)
{
js_pushnumber(J, cos(js_tonumber(J, 1)));
return 1;
}
static int Math_exp(js_State *J, int argc) {
return js_pushnumber(J, exp(js_tonumber(J, 1))), 1;
static int Math_exp(js_State *J, int argc)
{
js_pushnumber(J, exp(js_tonumber(J, 1)));
return 1;
}
static int Math_floor(js_State *J, int argc) {
return js_pushnumber(J, floor(js_tonumber(J, 1))), 1;
static int Math_floor(js_State *J, int argc)
{
js_pushnumber(J, floor(js_tonumber(J, 1)));
return 1;
}
static int Math_log(js_State *J, int argc) {
return js_pushnumber(J, log(js_tonumber(J, 1))), 1;
static int Math_log(js_State *J, int argc)
{
js_pushnumber(J, log(js_tonumber(J, 1)));
return 1;
}
static int Math_pow(js_State *J, int argc) {
return js_pushnumber(J, pow(js_tonumber(J, 1), js_tonumber(J, 2))), 1;
static int Math_pow(js_State *J, int argc)
{
js_pushnumber(J, pow(js_tonumber(J, 1), js_tonumber(J, 2)));
return 1;
}
static int Math_random(js_State *J, int argc) {
return js_pushnumber(J, (double)rand() / (RAND_MAX - 1)), 1;
static int Math_random(js_State *J, int argc)
{
js_pushnumber(J, (double)rand() / (RAND_MAX - 1));
return 1;
}
static int Math_round(js_State *J, int argc) {
return js_pushnumber(J, round(js_tonumber(J, 1))), 1;
static int Math_round(js_State *J, int argc)
{
js_pushnumber(J, round(js_tonumber(J, 1)));
return 1;
}
static int Math_sin(js_State *J, int argc) {
return js_pushnumber(J, sin(js_tonumber(J, 1))), 1;
static int Math_sin(js_State *J, int argc)
{
js_pushnumber(J, sin(js_tonumber(J, 1)));
return 1;
}
static int Math_sqrt(js_State *J, int argc) {
return js_pushnumber(J, sqrt(js_tonumber(J, 1))), 1;
static int Math_sqrt(js_State *J, int argc)
{
js_pushnumber(J, sqrt(js_tonumber(J, 1)));
return 1;
}
static int Math_tan(js_State *J, int argc) {
return js_pushnumber(J, tan(js_tonumber(J, 1))), 1;
static int Math_tan(js_State *J, int argc)
{
js_pushnumber(J, tan(js_tonumber(J, 1)));
return 1;
}
static int Math_max(js_State *J, int argc)