OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 // Patch file for dart:math library. | 5 // Patch file for dart:math library. |
6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
7 import 'dart:_js_helper' show patch, checkNum; | 7 import 'dart:_js_helper' show patch, checkNum; |
8 import 'dart:typed_data' show ByteData; | 8 import 'dart:typed_data' show ByteData; |
9 | 9 |
10 @patch | 10 @patch |
| 11 T min<T extends num>(T a, T b) => |
| 12 JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as T; |
| 13 |
| 14 @patch |
| 15 T max<T extends num>(T a, T b) => |
| 16 JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as T; |
| 17 |
| 18 @patch |
11 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); | 19 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); |
12 | 20 |
13 @patch | 21 @patch |
14 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); | 22 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); |
15 | 23 |
16 @patch | 24 @patch |
17 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); | 25 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); |
18 | 26 |
19 @patch | 27 @patch |
20 double tan(num radians) => JS('num', r'Math.tan(#)', checkNum(radians)); | 28 double tan(num radians) => JS('num', r'Math.tan(#)', checkNum(radians)); |
(...skipping 289 matching lines...) Loading... |
310 // last range of k*max .. 256**byteCount. | 318 // last range of k*max .. 256**byteCount. |
311 // TODO: Consider picking a higher byte count if the last range is a | 319 // TODO: Consider picking a higher byte count if the last range is a |
312 // significant portion of the entire range - a 50% chance of having | 320 // significant portion of the entire range - a 50% chance of having |
313 // to use two more bytes is no worse than always using one more. | 321 // to use two more bytes is no worse than always using one more. |
314 if (random - result + max < randomLimit) { | 322 if (random - result + max < randomLimit) { |
315 return result; | 323 return result; |
316 } | 324 } |
317 } | 325 } |
318 } | 326 } |
319 } | 327 } |
OLD | NEW |