MCPcopy Create free account
hub / github.com/mozilla/rhino / round

Method round

rhino/src/main/java/org/mozilla/javascript/NativeMath.java:583–601  ·  view source on GitHub ↗
(
            Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args)

Source from the content-addressed store, hash-verified

581 }
582
583 private static Object round(
584 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
585 double x = ScriptRuntime.toNumber(args, 0);
586 if (!Double.isNaN(x) && !Double.isInfinite(x)) {
587 // Round only finite x
588 long l = Math.round(x);
589 if (l != 0) {
590 x = l;
591 } else {
592 // We must propagate the sign of d into the result
593 if (x < 0.0) {
594 x = ScriptRuntime.negativeZero;
595 } else if (x != 0.0) {
596 x = 0.0;
597 }
598 }
599 }
600 return ScriptRuntime.wrapNumber(x);
601 }
602
603 private static Object sign(
604 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {

Callers 12

coerceTypeImplMethod · 0.80
ToArray-001.jsFile · 0.80
regress-329383.jsFile · 0.80
writeSuiteSummaryMethod · 0.80
15.8.2.15.jsFile · 0.80
statsTextMethod · 0.80
sc_lcmFunction · 0.80
UFunction · 0.80
DrawLineFunction · 0.80
UFunction · 0.80
DrawLineFunction · 0.80
sc_lcmFunction · 0.80

Calls 3

toNumberMethod · 0.95
wrapNumberMethod · 0.95
isNaNMethod · 0.45

Tested by 2

writeSuiteSummaryMethod · 0.64
statsTextMethod · 0.64