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

Unified Diff: runtime/lib/math_patch.dart

Issue 10919323: - Fix the implementation of Random.nextBool() and add test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/math/coin_test.dart » ('j') | tests/lib/math/coin_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/math_patch.dart
===================================================================
--- runtime/lib/math_patch.dart (revision 12454)
+++ runtime/lib/math_patch.dart (working copy)
@@ -60,16 +60,16 @@
do {
rnd32 = _nextInt32();
result = rnd32 % max;
- } while (rnd32 - result + max >= _POW2_32);
+ } while ((rnd32 - result + max) >= _POW2_32);
return result;
}
double nextDouble() {
- return ((nextInt(1 << (26)) << 27) + nextInt(1 << 27)) / _POW2_53_D;
+ return ((nextInt(1 << 26) << 27) + nextInt(1 << 27)) / _POW2_53_D;
}
bool nextBool() {
- return nextInt(1) == 0;
+ return nextInt(2) == 0;
Ivan Posva 2012/09/17 21:22:13 This is the only functional change!
}
// Constants used by the algorithm or masking.
« no previous file with comments | « no previous file | tests/lib/math/coin_test.dart » ('j') | tests/lib/math/coin_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698