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

Side by Side Diff: runtime/lib/math_patch.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 3 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/bin/websocket_impl.dart ('k') | runtime/lib/string.dart » ('j') | 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) 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 // A VM patch of the dart:math library. 5 // A VM patch of the dart:math library.
6
7 patch int parseInt(String str) => MathNatives.parseInt(str); 6 patch int parseInt(String str) => MathNatives.parseInt(str);
8
9 patch double parseDouble(String str) => MathNatives.parseDouble(str); 7 patch double parseDouble(String str) => MathNatives.parseDouble(str);
10 8 patch num pow(num x, num exponent) => MathNatives.pow(x, exponent);
11 patch double atan2(num a, num b) => MathNatives.atan2(a, b); 9 patch double atan2(num a, num b) => MathNatives.atan2(a, b);
12
13 patch num pow(num x, num exponent) => MathNatives.pow(x, exponent);
14
15 patch double sin(num x) => MathNatives.sin(x); 10 patch double sin(num x) => MathNatives.sin(x);
16 patch double cos(num x) => MathNatives.cos(x); 11 patch double cos(num x) => MathNatives.cos(x);
17 patch double tan(num x) => MathNatives.tan(x); 12 patch double tan(num x) => MathNatives.tan(x);
18 patch double acos(num x) => MathNatives.acos(x); 13 patch double acos(num x) => MathNatives.acos(x);
19 patch double asin(num x) => MathNatives.asin(x); 14 patch double asin(num x) => MathNatives.asin(x);
20 patch double atan(num x) => MathNatives.atan(x); 15 patch double atan(num x) => MathNatives.atan(x);
21 patch double sqrt(num x) => MathNatives.sqrt(x); 16 patch double sqrt(num x) => MathNatives.sqrt(x);
22 patch double exp(num x) => MathNatives.exp(x); 17 patch double exp(num x) => MathNatives.exp(x);
23 patch double log(num x) => MathNatives.log(x); 18 patch double log(num x) => MathNatives.log(x);
24 19
(...skipping 11 matching lines...) Expand all
36 return new _Random._internal(seed); 31 return new _Random._internal(seed);
37 } 32 }
38 } 33 }
39 34
40 35
41 class _Random implements Random { 36 class _Random implements Random {
42 // Internal state of the random number generator. 37 // Internal state of the random number generator.
43 var _state; 38 var _state;
44 39
45 _Random._internal(this._state); 40 _Random._internal(this._state);
46 41
47 // The algorithm used here is Multiply with Carry (MWC) with a Base b = 2^32. 42 // The algorithm used here is Multiply with Carry (MWC) with a Base b = 2^32.
48 // http://en.wikipedia.org/wiki/Multiply-with-carry 43 // http://en.wikipedia.org/wiki/Multiply-with-carry
49 // The constant A is selected from "Numerical Recipes 3rd Edition" p.348 B1. 44 // The constant A is selected from "Numerical Recipes 3rd Edition" p.348 B1.
50 int _nextInt32() { 45 int _nextInt32() {
51 _state = ((_A * (_state & _MASK_32)) + (_state >> 32)) & _MASK_64; 46 _state = ((_A * (_state & _MASK_32)) + (_state >> 32)) & _MASK_64;
52 return _state & _MASK_32; 47 return _state & _MASK_32;
53 } 48 }
54 49
55 int nextInt(int max) { 50 int nextInt(int max) {
56 if (max <= 0 || max > _POW2_32) { 51 if (max <= 0 || max > _POW2_32) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 static int _nextSeed() { 88 static int _nextSeed() {
94 if (_prng == null) { 89 if (_prng == null) {
95 // TODO(iposva): Use system to get a random seed. 90 // TODO(iposva): Use system to get a random seed.
96 _prng = new Random(new Date.now().millisecondsSinceEpoch); 91 _prng = new Random(new Date.now().millisecondsSinceEpoch);
97 } 92 }
98 // Trigger the PRNG once to change the internal state. 93 // Trigger the PRNG once to change the internal state.
99 _prng._nextInt32(); 94 _prng._nextInt32();
100 return _prng._state; 95 return _prng._state;
101 } 96 }
102 } 97 }
OLDNEW
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | runtime/lib/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698