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

Method abs

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

Source from the content-addressed store, hash-verified

89 }
90
91 private static Object abs(
92 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {
93 double x = ScriptRuntime.toNumber(args, 0);
94 // abs(-0.0) should be 0.0, but -0.0 < 0.0 == false
95 x = (x == 0.0) ? 0.0 : (x < 0.0) ? -x : x;
96
97 return ScriptRuntime.wrapNumber(x);
98 }
99
100 private static Object acos(
101 Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) {

Callers 15

assert.jsFile · 0.80
assertRoundsToMethod · 0.80
testSequentialValuesMethod · 0.80
testCommonFloatValuesMethod · 0.80
TimeClipMethod · 0.80
coerceToNumberMethod · 0.80
writeFloat16Method · 0.80
toExponentialMethod · 0.80
toFixedMethod · 0.80
computeRawStackMapMethod · 0.80

Calls 2

toNumberMethod · 0.95
wrapNumberMethod · 0.95

Tested by 5

assertRoundsToMethod · 0.64
testSequentialValuesMethod · 0.64
testCommonFloatValuesMethod · 0.64