| 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 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*/; | 12 JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as num/*=T*/; |
| 13 | 13 |
| 14 @patch | 14 @patch |
| 15 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) => | 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*/; | 16 JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as num/*=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 x) => JS('num', r'Math.sin(#)', checkNum(x)); | 22 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); |
| 23 | 23 |
| 24 @patch | 24 @patch |
| 25 double cos(num x) => JS('num', r'Math.cos(#)', checkNum(x)); | 25 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); |
| 26 | 26 |
| 27 @patch | 27 @patch |
| 28 double tan(num x) => JS('num', r'Math.tan(#)', checkNum(x)); | 28 double tan(num radians) => JS('num', r'Math.tan(#)', checkNum(radians)); |
| 29 | 29 |
| 30 @patch | 30 @patch |
| 31 double acos(num x) => JS('num', r'Math.acos(#)', checkNum(x)); | 31 double acos(num x) => JS('num', r'Math.acos(#)', checkNum(x)); |
| 32 | 32 |
| 33 @patch | 33 @patch |
| 34 double asin(num x) => JS('num', r'Math.asin(#)', checkNum(x)); | 34 double asin(num x) => JS('num', r'Math.asin(#)', checkNum(x)); |
| 35 | 35 |
| 36 @patch | 36 @patch |
| 37 double atan(num x) => JS('num', r'Math.atan(#)', checkNum(x)); | 37 double atan(num x) => JS('num', r'Math.atan(#)', checkNum(x)); |
| 38 | 38 |
| (...skipping 279 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 |