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

Side by Side Diff: tests/lib/math/double_pow_test.dart

Issue 220723017: Add optimization for pow(base, 0.5) to the other architectures as well. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--optimization-counter-threshold=5
4 5
5 library math_test; 6 library math_test;
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 import 'dart:math'; 8 import 'dart:math';
8 9
9 void checkVeryClose(double a, double b) { 10 void checkVeryClose(double a, double b) {
10 // We find a ulp (unit in the last place) by shifting the original number 11 // We find a ulp (unit in the last place) by shifting the original number
11 // to the right. This only works if we are not too close to infinity or if 12 // to the right. This only works if we are not too close to infinity or if
12 // we work with denormals. 13 // we work with denormals.
13 // We special case or 0.0, but not for infinity. 14 // We special case or 0.0, but not for infinity.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 -0.5, // Non-integer, magnitude < 1. 47 -0.5, // Non-integer, magnitude < 1.
47 -0.0, 48 -0.0,
48 0.5, // Non-integer, magnitude < 1. 49 0.5, // Non-integer, magnitude < 1.
49 1.0, // Unit 50 1.0, // Unit
50 1.5, // Non-integer, magnitude > 1 51 1.5, // Non-integer, magnitude > 1
51 2.0, // Even integer 52 2.0, // Even integer
52 3.0, // Odd integer 53 3.0, // Odd integer
53 Infinity 54 Infinity
54 ]; 55 ];
55 56
56 main() { 57 test() {
57 // Tests of pow(x, y): 58 // Tests of pow(x, y):
58 for (var d in samples) { 59 for (var d in samples) {
59 // if `y` is zero (0.0 or -0.0), the result is always 1.0. 60 // if `y` is zero (0.0 or -0.0), the result is always 1.0.
60 Expect.identical(1.0, pow(d, 0.0), "$d"); 61 Expect.identical(1.0, pow(d, 0.0), "$d");
61 Expect.identical(1.0, pow(d, -0.0), "$d"); 62 Expect.identical(1.0, pow(d, -0.0), "$d");
62 } 63 }
63 for (var d in samples) { 64 for (var d in samples) {
64 // if `x` is 1.0, the result is always 1.0. 65 // if `x` is 1.0, the result is always 1.0.
65 Expect.identical(1.0, pow(1.0, d), "$d"); 66 Expect.identical(1.0, pow(1.0, d), "$d");
66 } 67 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Underflow. 150 // Underflow.
150 Expect.identical(0.0, pow(10.0, -325.0)); 151 Expect.identical(0.0, pow(10.0, -325.0));
151 152
152 // Conversion to double. 153 // Conversion to double.
153 154
154 // The second argument is an odd integer as int, but not when converted 155 // The second argument is an odd integer as int, but not when converted
155 // to double. 156 // to double.
156 Expect.identical(Infinity, pow(-0.0, -9223372036854775809)); 157 Expect.identical(Infinity, pow(-0.0, -9223372036854775809));
157 } 158 }
158 159
160 main() {
161 for (int i = 0; i < 10; i++) test();
162 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698