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 class _Double implements double { | 5 class _Double implements double { |
6 factory _Double.fromInteger(int value) | 6 factory _Double.fromInteger(int value) |
7 native "Double_doubleFromInteger"; | 7 native "Double_doubleFromInteger"; |
8 | 8 |
9 Type get runtimeType => double; | 9 Type get runtimeType => double; |
10 | 10 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } else { | 270 } else { |
271 return EQUAL; | 271 return EQUAL; |
272 } | 272 } |
273 } else if (isNaN) { | 273 } else if (isNaN) { |
274 return other.isNaN ? EQUAL : GREATER; | 274 return other.isNaN ? EQUAL : GREATER; |
275 } else { | 275 } else { |
276 // Other is NaN. | 276 // Other is NaN. |
277 return LESS; | 277 return LESS; |
278 } | 278 } |
279 } | 279 } |
| 280 |
| 281 static const int _FRACTIONAL_BITS = // Bits to keep after the decimal point. |
| 282 const int.fromEnvironment("doubleFractionalBits", defaultValue: 20); |
| 283 static const double _BIAS = 1.5 * (1 << (52 - _FRACTIONAL_BITS)); |
| 284 |
| 285 // Returns this with only _FRACTIONAL_BITS bits after the decimal point. |
| 286 double get p => this + _BIAS - _BIAS; |
280 } | 287 } |
OLD | NEW |