From ca79fc1497f30fc4f3bb9bcdc58490b1a93fc476 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 21 Jan 2014 14:14:51 +0100 Subject: [PATCH] jsmath.c expanded --- jsmath.c | 111 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 32 deletions(-) diff --git a/jsmath.c b/jsmath.c index a6dd455..35fb59e 100644 --- a/jsmath.c +++ b/jsmath.c @@ -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)