| Index: lib/double.dart
|
| ===================================================================
|
| --- lib/double.dart (revision 394)
|
| +++ lib/double.dart (working copy)
|
| @@ -12,38 +12,47 @@
|
| return 0;
|
| }
|
| }
|
| +
|
| + // Verified double conversion.
|
| + static double _checkedToDouble(num value) {
|
| + if (value is !num) {
|
| + throw const IllegalArgumentException("num value expected");
|
| + }
|
| + return value.toDouble();
|
| + }
|
| +
|
| double operator +(num other) {
|
| - return add_(other.toDouble());
|
| + return add_(_checkedToDouble(other));
|
| }
|
| double add_(double other) native "Double_add";
|
|
|
| double operator -(num other) {
|
| - return sub_(other.toDouble());
|
| + return sub_(_checkedToDouble(other));
|
| }
|
| double sub_(double other) native "Double_sub";
|
|
|
| double operator *(num other) {
|
| - return mul_(other.toDouble());
|
| + return mul_(_checkedToDouble(other));
|
| }
|
| double mul_(double other) native "Double_mul";
|
|
|
| double operator ~/(num other) {
|
| - return trunc_div_(other.toDouble());
|
| + return trunc_div_(_checkedToDouble(other));
|
| }
|
| double trunc_div_(double other) native "Double_trunc_div";
|
|
|
| double operator /(num other) {
|
| - return div_(other.toDouble());
|
| + return div_(_checkedToDouble(other));
|
| }
|
| double div_(double other) native "Double_div";
|
|
|
| double operator %(num other) {
|
| - return modulo_(other.toDouble());
|
| + return modulo_(_checkedToDouble(other));
|
| }
|
| double modulo_(double other) native "Double_modulo";
|
|
|
| double remainder(num other) {
|
| - return remainder_(other.toDouble());
|
| + return remainder_(_checkedToDouble(other));
|
| }
|
| double remainder_(double other) native "Double_remainder";
|
|
|
| @@ -52,7 +61,7 @@
|
| }
|
| bool operator ==(other) {
|
| if (!(other is num)) return false;
|
| - return equal_(other.toDouble());
|
| + return equal_(_checkedToDouble(other));
|
| }
|
| bool equal_(double other)native "Double_equal";
|
| bool equalToInteger(int other) native "Double_equalToInteger";
|
| @@ -60,7 +69,7 @@
|
| return other > this;
|
| }
|
| bool operator >(num other) {
|
| - return greaterThan_(other.toDouble());
|
| + return greaterThan_(_checkedToDouble(other));
|
| }
|
| bool greaterThan_(double other) native "Double_greaterThan";
|
| bool operator >=(num other) {
|
|
|