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

Side by Side Diff: pkg/fixnum/int32.dart

Issue 11227042: isEven, isOdd, isNegative, isMaxValue, isMinValue, isInfinite, isPositive, isSingleValue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** 5 /**
6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1].
7 * Arithmetic operations may overflow in order to maintain this range. 7 * Arithmetic operations may overflow in order to maintain this range.
8 */ 8 */
9 class int32 implements intx { 9 class int32 implements intx {
10 10
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return _i > _convert(other); 314 return _i > _convert(other);
315 } 315 }
316 316
317 bool operator >=(other) { 317 bool operator >=(other) {
318 if (other is int64) { 318 if (other is int64) {
319 return this.toInt64() < other; 319 return this.toInt64() < other;
320 } 320 }
321 return _i >= _convert(other); 321 return _i >= _convert(other);
322 } 322 }
323 323
324 bool isEven() => (_i & 0x1) == 0; 324 bool get isEven => (_i & 0x1) == 0;
325 bool isMaxValue() => _i == 2147483647; 325 bool get isMaxValue => _i == 2147483647;
326 bool isMinValue() => _i == -2147483648; 326 bool get isMinValue => _i == -2147483648;
327 bool isNegative() => _i < 0; 327 bool get isNegative => _i < 0;
328 bool isOdd() => (_i & 0x1) == 1; 328 bool get isOdd => (_i & 0x1) == 1;
329 bool isZero() => _i == 0; 329 bool get isZero => _i == 0;
330 330
331 int get hashCode => _i; 331 int get hashCode => _i;
332 332
333 int32 abs() => _i < 0 ? new int32.fromInt(-_i) : this; 333 int32 abs() => _i < 0 ? new int32.fromInt(-_i) : this;
334 334
335 int numberOfLeadingZeros() => _numberOfLeadingZeros(_i); 335 int numberOfLeadingZeros() => _numberOfLeadingZeros(_i);
336 int numberOfTrailingZeros() => _numberOfTrailingZeros(_i); 336 int numberOfTrailingZeros() => _numberOfTrailingZeros(_i);
337 337
338 List<int> toBytes() { 338 List<int> toBytes() {
339 List<int> result = new List<int>(4); 339 List<int> result = new List<int>(4);
340 result[0] = _i & 0xff; 340 result[0] = _i & 0xff;
341 result[1] = (_i >> 8) & 0xff; 341 result[1] = (_i >> 8) & 0xff;
342 result[2] = (_i >> 16) & 0xff; 342 result[2] = (_i >> 16) & 0xff;
343 result[3] = (_i >> 24) & 0xff; 343 result[3] = (_i >> 24) & 0xff;
344 return result; 344 return result;
345 } 345 }
346 346
347 int toInt() => _i; 347 int toInt() => _i;
348 int32 toInt32() => this; 348 int32 toInt32() => this;
349 int64 toInt64() => new int64.fromInt(_i); 349 int64 toInt64() => new int64.fromInt(_i);
350 350
351 String toString() => _i.toString(); 351 String toString() => _i.toString();
352 String toHexString() => _i.toRadixString(16); 352 String toHexString() => _i.toRadixString(16);
353 String toRadixString(int radix) => _i.toRadixString(radix); 353 String toRadixString(int radix) => _i.toRadixString(radix);
354 } 354 }
OLDNEW
« lib/core/int.dart ('K') | « lib/math/base.dart ('k') | pkg/fixnum/int64.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698