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

Side by Side Diff: sdk/lib/core/int.dart

Issue 1510573002: Fix comment on int.toUnsigned() (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * An arbitrarily large integer. 8 * An arbitrarily large integer.
9 * 9 *
10 * **Note:** When compiling to JavaScript, integers are 10 * **Note:** When compiling to JavaScript, integers are
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 * (-3).bitLength == 2; // 11111101 163 * (-3).bitLength == 2; // 11111101
164 * (-4).bitLength == 2; // 11111100 164 * (-4).bitLength == 2; // 11111100
165 */ 165 */
166 int get bitLength; 166 int get bitLength;
167 167
168 /** 168 /**
169 * Returns the least significant [width] bits of this integer as a 169 * Returns the least significant [width] bits of this integer as a
170 * non-negative number (i.e. unsigned representation). The returned value has 170 * non-negative number (i.e. unsigned representation). The returned value has
171 * zeros in all bit positions higher than [width]. 171 * zeros in all bit positions higher than [width].
172 * 172 *
173 * (-1).toUnsigned(5) == 32 // 11111111 -> 00011111 173 * (-1).toUnsigned(5) == 31 // 11111111 -> 00011111
174 * 174 *
175 * This operation can be used to simulate arithmetic from low level languages. 175 * This operation can be used to simulate arithmetic from low level languages.
176 * For example, to increment an 8 bit quantity: 176 * For example, to increment an 8 bit quantity:
177 * 177 *
178 * q = (q + 1).toUnsigned(8); 178 * q = (q + 1).toUnsigned(8);
179 * 179 *
180 * `q` will count from `0` up to `255` and then wrap around to `0`. 180 * `q` will count from `0` up to `255` and then wrap around to `0`.
181 * 181 *
182 * If the input fits in [width] bits without truncation, the result is the 182 * If the input fits in [width] bits without truncation, the result is the
183 * same as the input. The minimum width needed to avoid truncation of `x` is 183 * same as the input. The minimum width needed to avoid truncation of `x` is
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 * var value = int.parse(text, onError: (source) => null); 311 * var value = int.parse(text, onError: (source) => null);
312 * if (value == null) ... handle the problem 312 * if (value == null) ... handle the problem
313 * 313 *
314 * The [onError] function is only invoked if [source] is a [String]. It is 314 * The [onError] function is only invoked if [source] is a [String]. It is
315 * not invoked if the [source] is, for example, `null`. 315 * not invoked if the [source] is, for example, `null`.
316 */ 316 */
317 external static int parse(String source, 317 external static int parse(String source,
318 { int radix, 318 { int radix,
319 int onError(String source) }); 319 int onError(String source) });
320 } 320 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698