Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js2py/constructors/jsmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ def max():

def random():
return random.random()

def sign(x):
a = x.to_number().value
if a != a: # it must be a nan
return NaN
return math.copysign(1, a)


fill_prototype(Math, MathFunctions, default_attrs)