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

Unified Diff: runtime/lib/double.dart

Issue 2208473006: Introduce getter p on double in the VM to control fractional precision. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 4 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/standalone/fixed_precision_double_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.dart
diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart
index ade4b9317bcd75c3c5150c78372a803f8630516d..34d780341d79f5626343c093d839ea07332d3f95 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -277,4 +277,11 @@ class _Double implements double {
return LESS;
}
}
+
+ static const int _FRACTIONAL_BITS = // Bits to keep after the decimal point.
+ const int.fromEnvironment("doubleFractionalBits", defaultValue: 20);
+ static const double _BIAS = 1.5 * (1 << (52 - _FRACTIONAL_BITS));
+
+ // Returns this with only _FRACTIONAL_BITS bits after the decimal point.
+ double get p => this + _BIAS - _BIAS;
}
« no previous file with comments | « no previous file | tests/standalone/fixed_precision_double_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698