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) | |
12 => JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as num/*=T*/; | |
vsm
2016/09/30 19:36:33
Do we actually need the checkNum? Would a null ch
Bob Nystrom
2016/09/30 19:43:14
Good question. I was just following the nearby cod
| |
13 | |
14 @patch | |
15 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) | |
16 => JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as num/*=T*/; | |
17 | |
18 @patch | |
11 double sqrt(num x) | 19 double sqrt(num x) |
12 => JS('num', r'Math.sqrt(#)', checkNum(x)); | 20 => JS('num', r'Math.sqrt(#)', checkNum(x)); |
13 | 21 |
14 @patch | 22 @patch |
15 double sin(num x) | 23 double sin(num x) |
16 => JS('num', r'Math.sin(#)', checkNum(x)); | 24 => JS('num', r'Math.sin(#)', checkNum(x)); |
17 | 25 |
18 @patch | 26 @patch |
19 double cos(num x) | 27 double cos(num x) |
20 => JS('num', r'Math.cos(#)', checkNum(x)); | 28 => JS('num', r'Math.cos(#)', checkNum(x)); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 // last range of k*max .. 256**byteCount. | 329 // last range of k*max .. 256**byteCount. |
322 // TODO: Consider picking a higher byte count if the last range is a | 330 // TODO: Consider picking a higher byte count if the last range is a |
323 // significant portion of the entire range - a 50% chance of having | 331 // significant portion of the entire range - a 50% chance of having |
324 // to use two more bytes is no worse than always using one more. | 332 // to use two more bytes is no worse than always using one more. |
325 if (random - result + max < randomLimit) { | 333 if (random - result + max < randomLimit) { |
326 return result; | 334 return result; |
327 } | 335 } |
328 } | 336 } |
329 } | 337 } |
330 } | 338 } |
OLD | NEW |