Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Side by Side Diff: test/mjsunit/es6/math-log2-log10.js

Issue 2083453002: [builtins] Introduce proper Float64Tan operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/double-intrinsics.js ('k') | test/unittests/base/ieee754-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Test denormals. 50 // Test denormals.
51 assertEquals(-307.77759430519706, Math.log10(1.5 * Math.pow(2, -1023))); 51 assertEquals(-307.77759430519706, Math.log10(1.5 * Math.pow(2, -1023)));
52 52
53 // Issue 4025. Remove delta once issue 4029 has been fixed. 53 // Issue 4025. Remove delta once issue 4029 has been fixed.
54 assertEqualsDelta(-9.643274665532873e-17, Math.log10(1-Number.EPSILON), 3e-32); 54 assertEqualsDelta(-9.643274665532873e-17, Math.log10(1-Number.EPSILON), 3e-32);
55 55
56 // Test Math.log2(2^k) for -1074 <= k <= 1023. 56 // Test Math.log2(2^k) for -1074 <= k <= 1023.
57 var n = -1074; 57 var n = -1074;
58 // This loop covers n from -1074 to -1043 58 // This loop covers n from -1074 to -1043
59 for (var lowbits = 1; lowbits <= 0x80000000; lowbits *= 2) { 59 for (var lowbits = 1; lowbits <= 0x80000000; lowbits *= 2) {
60 var x = %_ConstructDouble(0, lowbits); 60 var x = %ConstructDouble(0, lowbits);
61 assertEquals(n, Math.log2(x)); 61 assertEquals(n, Math.log2(x));
62 n++; 62 n++;
63 } 63 }
64 // This loop covers n from -1042 to -1023 64 // This loop covers n from -1042 to -1023
65 for (var hibits = 1; hibits <= 0x80000; hibits *= 2) { 65 for (var hibits = 1; hibits <= 0x80000; hibits *= 2) {
66 var x = %_ConstructDouble(hibits, 0); 66 var x = %ConstructDouble(hibits, 0);
67 assertEquals(n, Math.log2(x)); 67 assertEquals(n, Math.log2(x));
68 n++; 68 n++;
69 } 69 }
70 // The rest of the normal values of 2^n 70 // The rest of the normal values of 2^n
71 var x = 1; 71 var x = 1;
72 for (var n = -1022; n <= 1023; ++n) { 72 for (var n = -1022; n <= 1023; ++n) {
73 var x = Math.pow(2, n); 73 var x = Math.pow(2, n);
74 assertEquals(n, Math.log2(x)); 74 assertEquals(n, Math.log2(x));
75 } 75 }
76 76
(...skipping 16 matching lines...) Expand all
93 } 93 }
94 94
95 x = Math.pow(2, -100); 95 x = Math.pow(2, -100);
96 for (var k = 0; k < 1000; ++k) { 96 for (var k = 0; k < 1000; ++k) {
97 var y = Math.log2(x); 97 var y = Math.log2(x);
98 var expected = Math.log(x) / Math.LN2; 98 var expected = Math.log(x) / Math.LN2;
99 var err = Math.abs(y - expected) / expected; 99 var err = Math.abs(y - expected) / expected;
100 assertEqualsDelta(0, err, 1e-15); 100 assertEqualsDelta(0, err, 1e-15);
101 x *= 1.1; 101 x *= 1.1;
102 } 102 }
OLDNEW
« no previous file with comments | « test/mjsunit/double-intrinsics.js ('k') | test/unittests/base/ieee754-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698