Debian Codegraph @

js/src/tests/test262/built-ins/Math/abs/absolute-value.js

raw
1 // Copyright (C) 2016 The V8 Project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-math.abs
6 description: >
7 Returns the absolute value of x
8 info: |
9 Math.abs ( x )
10
11 Returns the absolute value of x; the result has the same magnitude as x but
12 has positive sign.
13 ---*/
14
15 assert.sameValue(Math.abs(-42), 42, "-42");
16 assert.sameValue(Math.abs(42), 42, "42");
17 assert.sameValue(Math.abs(-0.000001), 0.000001, "-0.000001");
18 assert.sameValue(Math.abs(0.000001), 0.000001, "0.000001");
19 assert.sameValue(Math.abs(-1e-17), 1e-17, "-1e-17");
20 assert.sameValue(Math.abs(1e-17), 1e-17, "1e-17");
21 assert.sameValue(Math.abs(-9007199254740991), 9007199254740991, "-(2**53-1)");
22 assert.sameValue(Math.abs(9007199254740991), 9007199254740991, "2**53-1");
23
24 reportCompare(0, 0);