| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 int hashCode() { | 8 int hashCode() { |
| 9 try { | 9 try { |
| 10 return toInt(); | 10 return toInt(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return modulo_(other.toDouble()); | 41 return modulo_(other.toDouble()); |
| 42 } | 42 } |
| 43 double modulo_(double other) native "Double_modulo"; | 43 double modulo_(double other) native "Double_modulo"; |
| 44 | 44 |
| 45 double remainder(num other) { | 45 double remainder(num other) { |
| 46 return remainder_(other.toDouble()); | 46 return remainder_(other.toDouble()); |
| 47 } | 47 } |
| 48 double remainder_(double other) native "Double_remainder"; | 48 double remainder_(double other) native "Double_remainder"; |
| 49 | 49 |
| 50 double operator negate() { | 50 double operator negate() { |
| 51 if (this == 0.0) { |
| 52 // -0.0 is canonicalized by the VM's parser, therefore no cycles. |
| 53 return isNegative() ? 0.0 : -0.0; |
| 54 } |
| 51 return 0.0 - this; | 55 return 0.0 - this; |
| 52 } | 56 } |
| 53 bool operator ==(other) { | 57 bool operator ==(other) { |
| 54 if (!(other is num)) return false; | 58 if (!(other is num)) return false; |
| 55 return equal_(other.toDouble()); | 59 return equal_(other.toDouble()); |
| 56 } | 60 } |
| 57 bool equal_(double other)native "Double_equal"; | 61 bool equal_(double other)native "Double_equal"; |
| 58 bool equalToInteger(int other) native "Double_equalToInteger"; | 62 bool equalToInteger(int other) native "Double_equalToInteger"; |
| 59 bool operator <(num other) { | 63 bool operator <(num other) { |
| 60 return other > this; | 64 return other > this; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return EQUAL; | 201 return EQUAL; |
| 198 } | 202 } |
| 199 } else if (isNaN()) { | 203 } else if (isNaN()) { |
| 200 return other.isNaN() ? EQUAL : GREATER; | 204 return other.isNaN() ? EQUAL : GREATER; |
| 201 } else { | 205 } else { |
| 202 // Other is NaN. | 206 // Other is NaN. |
| 203 return LESS; | 207 return LESS; |
| 204 } | 208 } |
| 205 } | 209 } |
| 206 } | 210 } |
| OLD | NEW |