From 81d5b30accd3094e8feb44126e4dccf2f6e6c9e3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 26 Oct 2018 14:50:20 +0200 Subject: [PATCH] Initialize random seed for Math.random(). --- jsmath.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsmath.c b/jsmath.c index a4ea3a4..e904e08 100644 --- a/jsmath.c +++ b/jsmath.c @@ -2,6 +2,8 @@ #include "jsvalue.h" #include "jsbuiltin.h" +#include + static void Math_abs(js_State *J) { js_pushnumber(J, fabs(js_tonumber(J, 1))); @@ -138,6 +140,8 @@ static void Math_min(js_State *J) void jsB_initmath(js_State *J) { + srand(time(NULL)); + js_pushobject(J, jsV_newobject(J, JS_CMATH, J->Object_prototype)); { jsB_propn(J, "E", 2.7182818284590452354);