| 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 | 5 |
| 6 | 6 |
| 7 function native_NumberImplementation_BIT_OR(other) { | 7 function native_NumberImplementation_BIT_OR(other) { |
| 8 "use strict"; | 8 "use strict"; |
| 9 if (typeof other != 'number') { |
| 10 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 11 } |
| 9 return this | other; | 12 return this | other; |
| 10 } | 13 } |
| 11 | 14 |
| 12 function native_NumberImplementation_BIT_XOR(other) { | 15 function native_NumberImplementation_BIT_XOR(other) { |
| 13 "use strict"; | 16 "use strict"; |
| 17 if (typeof other != 'number') { |
| 18 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 19 } |
| 14 return this ^ other; | 20 return this ^ other; |
| 15 } | 21 } |
| 16 | 22 |
| 17 function native_NumberImplementation_BIT_AND(other) { | 23 function native_NumberImplementation_BIT_AND(other) { |
| 18 "use strict"; | 24 "use strict"; |
| 25 if (typeof other != 'number') { |
| 26 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 27 } |
| 19 return this & other; | 28 return this & other; |
| 20 } | 29 } |
| 21 | 30 |
| 22 function native_NumberImplementation_SHL(other) { | 31 function native_NumberImplementation_SHL(other) { |
| 23 "use strict"; | 32 "use strict"; |
| 33 if (typeof other != 'number') { |
| 34 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 35 } |
| 24 return this << other; | 36 return this << other; |
| 25 } | 37 } |
| 26 | 38 |
| 27 function native_NumberImplementation_SAR(other) { | 39 function native_NumberImplementation_SAR(other) { |
| 28 "use strict"; | 40 "use strict"; |
| 41 if (typeof other != 'number') { |
| 42 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 43 } |
| 29 return this >> other; | 44 return this >> other; |
| 30 } | 45 } |
| 31 | 46 |
| 32 function native_NumberImplementation_ADD(other) { | 47 function native_NumberImplementation_ADD(other) { |
| 33 "use strict"; | 48 "use strict"; |
| 49 if (typeof other != 'number') { |
| 50 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 51 } |
| 34 return this + other; | 52 return this + other; |
| 35 } | 53 } |
| 36 | 54 |
| 37 function native_NumberImplementation_SUB(other) { | 55 function native_NumberImplementation_SUB(other) { |
| 38 "use strict"; | 56 "use strict"; |
| 39 return this - other; | 57 if (typeof other != 'number') { |
| 58 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 59 } |
| 60 return this - other; |
| 40 } | 61 } |
| 41 | 62 |
| 42 function native_NumberImplementation_MUL(other) { | 63 function native_NumberImplementation_MUL(other) { |
| 43 "use strict"; | 64 "use strict"; |
| 65 if (typeof other != 'number') { |
| 66 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 67 } |
| 44 return this * other; | 68 return this * other; |
| 45 } | 69 } |
| 46 | 70 |
| 47 function native_NumberImplementation_DIV(other) { | 71 function native_NumberImplementation_DIV(other) { |
| 48 "use strict"; | 72 "use strict"; |
| 73 if (typeof other != 'number') { |
| 74 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 75 } |
| 49 return this / other; | 76 return this / other; |
| 50 } | 77 } |
| 51 | 78 |
| 52 function native_NumberImplementation_TRUNC(other) { | 79 function native_NumberImplementation_TRUNC(other) { |
| 53 "use strict"; | 80 "use strict"; |
| 81 if (typeof other != 'number') { |
| 82 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 83 } |
| 54 var tmp = this / other; | 84 var tmp = this / other; |
| 55 if (tmp < 0) { | 85 if (tmp < 0) { |
| 56 return Math.ceil(tmp); | 86 return Math.ceil(tmp); |
| 57 } else { | 87 } else { |
| 58 return Math.floor(tmp); | 88 return Math.floor(tmp); |
| 59 } | 89 } |
| 60 } | 90 } |
| 61 | 91 |
| 62 function number$euclideanModulo(a, b) { | 92 function number$euclideanModulo(a, b) { |
| 63 var result = a % b; | 93 var result = a % b; |
| 64 if (result == 0) { | 94 if (result == 0) { |
| 65 return 0; // Make sure we don't return -0.0. | 95 return 0; // Make sure we don't return -0.0. |
| 66 } else if (result < 0) { | 96 } else if (result < 0) { |
| 67 if (b < 0) { | 97 if (b < 0) { |
| 68 return result - b; | 98 return result - b; |
| 69 } else { | 99 } else { |
| 70 return result + b; | 100 return result + b; |
| 71 } | 101 } |
| 72 } | 102 } |
| 73 return result; | 103 return result; |
| 74 } | 104 } |
| 75 | 105 |
| 76 function native_NumberImplementation_MOD(other) { | 106 function native_NumberImplementation_MOD(other) { |
| 77 "use strict"; | 107 "use strict"; |
| 108 if (typeof other != 'number') { |
| 109 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 110 } |
| 78 return number$euclideanModulo(this, other); | 111 return number$euclideanModulo(this, other); |
| 79 } | 112 } |
| 80 | 113 |
| 81 function native_NumberImplementation_LT(other) { | 114 function native_NumberImplementation_LT(other) { |
| 82 "use strict"; | 115 "use strict"; |
| 116 if (typeof other != 'number') { |
| 117 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 118 } |
| 83 return this < other; | 119 return this < other; |
| 84 } | 120 } |
| 85 | 121 |
| 86 function native_NumberImplementation_GT(other) { | 122 function native_NumberImplementation_GT(other) { |
| 87 "use strict"; | 123 "use strict"; |
| 124 if (typeof other != 'number') { |
| 125 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 126 } |
| 88 return this > other; | 127 return this > other; |
| 89 } | 128 } |
| 90 | 129 |
| 91 function native_NumberImplementation_LTE(other) { | 130 function native_NumberImplementation_LTE(other) { |
| 92 "use strict"; | 131 "use strict"; |
| 132 if (typeof other != 'number') { |
| 133 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 134 } |
| 93 return this <= other; | 135 return this <= other; |
| 94 } | 136 } |
| 95 | 137 |
| 96 function native_NumberImplementation_GTE(other) { | 138 function native_NumberImplementation_GTE(other) { |
| 97 "use strict"; | 139 "use strict"; |
| 140 if (typeof other != 'number') { |
| 141 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 142 } |
| 98 return this >= other; | 143 return this >= other; |
| 99 } | 144 } |
| 100 | 145 |
| 101 function native_NumberImplementation_EQ(other) { | 146 function native_NumberImplementation_EQ(other) { |
| 102 "use strict"; | 147 "use strict"; |
| 103 return typeof other == 'number' && this == other; | 148 return typeof other == 'number' && this == other; |
| 104 } | 149 } |
| 105 | 150 |
| 106 function native_NumberImplementation_BIT_NOT() { | 151 function native_NumberImplementation_BIT_NOT() { |
| 107 "use strict"; | 152 "use strict"; |
| 108 return ~this; | 153 return ~this; |
| 109 } | 154 } |
| 110 | 155 |
| 111 function native_NumberImplementation_negate() { | 156 function native_NumberImplementation_negate() { |
| 112 "use strict"; | 157 "use strict"; |
| 113 return -this; | 158 return -this; |
| 114 } | 159 } |
| 115 | 160 |
| 116 function native_NumberImplementation_remainder(other) { | 161 function native_NumberImplementation_remainder(other) { |
| 117 "use strict"; | 162 "use strict"; |
| 163 if (typeof other != 'number') { |
| 164 native__NumberJsUtil__throwIllegalArgumentException(other); |
| 165 } |
| 118 return this % other; | 166 return this % other; |
| 119 } | 167 } |
| 120 | 168 |
| 121 function native_NumberImplementation_abs() { | 169 function native_NumberImplementation_abs() { |
| 122 "use strict"; | 170 "use strict"; |
| 123 return Math.abs(this); | 171 return Math.abs(this); |
| 124 } | 172 } |
| 125 | 173 |
| 126 function native_NumberImplementation_round() { | 174 function native_NumberImplementation_round() { |
| 127 "use strict"; | 175 "use strict"; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 return this.toExponential(fractionDigits); | 228 return this.toExponential(fractionDigits); |
| 181 } | 229 } |
| 182 function native_NumberImplementation_toRadixString(radix) { | 230 function native_NumberImplementation_toRadixString(radix) { |
| 183 return this.toString(radix); | 231 return this.toString(radix); |
| 184 } | 232 } |
| 185 | 233 |
| 186 function native_NumberImplementation_hashCode() { | 234 function native_NumberImplementation_hashCode() { |
| 187 "use strict"; | 235 "use strict"; |
| 188 return this & 0xFFFFFFF; | 236 return this & 0xFFFFFFF; |
| 189 } | 237 } |
| OLD | NEW |