| 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) { |