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 num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) => | 11 T min<T extends num>(T a, T b) => |
12 JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as num/*=T*/; | 12 JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as T; |
13 | 13 |
14 @patch | 14 @patch |
15 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) => | 15 T max<T extends num>(T a, T b) => |
16 JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as num/*=T*/; | 16 JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as T; |
17 | 17 |
18 @patch | 18 @patch |
19 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); | 19 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); |
20 | 20 |
21 @patch | 21 @patch |
22 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); | 22 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); |
23 | 23 |
24 @patch | 24 @patch |
25 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); | 25 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); |
26 | 26 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // last range of k*max .. 256**byteCount. | 318 // last range of k*max .. 256**byteCount. |
319 // 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 |
320 // significant portion of the entire range - a 50% chance of having | 320 // significant portion of the entire range - a 50% chance of having |
321 // 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. |
322 if (random - result + max < randomLimit) { | 322 if (random - result + max < randomLimit) { |
323 return result; | 323 return result; |
324 } | 324 } |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
OLD | NEW |