Skip to content

Commit b60e6f8

Browse files
authored
Rollup merge of rust-lang#46898 - tspiteri:int-overflow-not-underflow, r=steveklabnik
docs: do not call integer overflows as underflows In the API docs, integer overflow is sometimes called underflow. Underflow is really when the magnitude of a floating-point number is too small so the number underflows to subnormal or zero. With integers it is always overflow, even if the expected result is less than the minimum number that can be represented.
2 parents 8acc406 + 9d6bd05 commit b60e6f8

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

src/libcore/num/bignum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ macro_rules! define_bignum {
114114
/// copying it recklessly may result in the performance hit.
115115
/// Thus this is intentionally not `Copy`.
116116
///
117-
/// All operations available to bignums panic in the case of over/underflows.
117+
/// All operations available to bignums panic in the case of overflows.
118118
/// The caller is responsible to use large enough bignum types.
119119
pub struct $name {
120120
/// One plus the offset to the maximum "digit" in use.

src/libcore/num/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ macro_rules! int_impl {
399399
}
400400

401401
/// Checked integer subtraction. Computes `self - rhs`, returning
402-
/// `None` if underflow occurred.
402+
/// `None` if overflow occurred.
403403
///
404404
/// # Examples
405405
///
@@ -417,7 +417,7 @@ macro_rules! int_impl {
417417
}
418418

419419
/// Checked integer multiplication. Computes `self * rhs`, returning
420-
/// `None` if underflow or overflow occurred.
420+
/// `None` if overflow occurred.
421421
///
422422
/// # Examples
423423
///
@@ -435,7 +435,7 @@ macro_rules! int_impl {
435435
}
436436

437437
/// Checked integer division. Computes `self / rhs`, returning `None`
438-
/// if `rhs == 0` or the operation results in underflow or overflow.
438+
/// if `rhs == 0` or the operation results in overflow.
439439
///
440440
/// # Examples
441441
///
@@ -457,7 +457,7 @@ macro_rules! int_impl {
457457
}
458458

459459
/// Checked integer remainder. Computes `self % rhs`, returning `None`
460-
/// if `rhs == 0` or the operation results in underflow or overflow.
460+
/// if `rhs == 0` or the operation results in overflow.
461461
///
462462
/// # Examples
463463
///
@@ -1563,7 +1563,7 @@ macro_rules! uint_impl {
15631563
}
15641564

15651565
/// Checked integer subtraction. Computes `self - rhs`, returning
1566-
/// `None` if underflow occurred.
1566+
/// `None` if overflow occurred.
15671567
///
15681568
/// # Examples
15691569
///
@@ -1581,7 +1581,7 @@ macro_rules! uint_impl {
15811581
}
15821582

15831583
/// Checked integer multiplication. Computes `self * rhs`, returning
1584-
/// `None` if underflow or overflow occurred.
1584+
/// `None` if overflow occurred.
15851585
///
15861586
/// # Examples
15871587
///
@@ -1599,7 +1599,7 @@ macro_rules! uint_impl {
15991599
}
16001600

16011601
/// Checked integer division. Computes `self / rhs`, returning `None`
1602-
/// if `rhs == 0` or the operation results in underflow or overflow.
1602+
/// if `rhs == 0` or the operation results in overflow.
16031603
///
16041604
/// # Examples
16051605
///
@@ -1619,7 +1619,7 @@ macro_rules! uint_impl {
16191619
}
16201620

16211621
/// Checked integer remainder. Computes `self % rhs`, returning `None`
1622-
/// if `rhs == 0` or the operation results in underflow or overflow.
1622+
/// if `rhs == 0` or the operation results in overflow.
16231623
///
16241624
/// # Examples
16251625
///

src/libcore/ptr.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,7 @@ impl<T: ?Sized> *const T {
581581
/// * Both the starting and resulting pointer must be either in bounds or one
582582
/// byte past the end of an allocated object.
583583
///
584-
/// * The computed offset, **in bytes**, cannot overflow or underflow an
585-
/// `isize`.
584+
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
586585
///
587586
/// * The offset being in bounds cannot rely on "wrapping around" the address
588587
/// space. That is, the infinite-precision sum, **in bytes** must fit in a usize.
@@ -714,8 +713,7 @@ impl<T: ?Sized> *const T {
714713
/// * Both the starting and resulting pointer must be either in bounds or one
715714
/// byte past the end of an allocated object.
716715
///
717-
/// * The computed offset, **in bytes**, cannot overflow or underflow an
718-
/// `isize`.
716+
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
719717
///
720718
/// * The offset being in bounds cannot rely on "wrapping around" the address
721719
/// space. That is, the infinite-precision sum must fit in a `usize`.
@@ -1219,8 +1217,7 @@ impl<T: ?Sized> *mut T {
12191217
/// * Both the starting and resulting pointer must be either in bounds or one
12201218
/// byte past the end of an allocated object.
12211219
///
1222-
/// * The computed offset, **in bytes**, cannot overflow or underflow an
1223-
/// `isize`.
1220+
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
12241221
///
12251222
/// * The offset being in bounds cannot rely on "wrapping around" the address
12261223
/// space. That is, the infinite-precision sum, **in bytes** must fit in a usize.
@@ -1419,8 +1416,7 @@ impl<T: ?Sized> *mut T {
14191416
/// * Both the starting and resulting pointer must be either in bounds or one
14201417
/// byte past the end of an allocated object.
14211418
///
1422-
/// * The computed offset, **in bytes**, cannot overflow or underflow an
1423-
/// `isize`.
1419+
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
14241420
///
14251421
/// * The offset being in bounds cannot rely on "wrapping around" the address
14261422
/// space. That is, the infinite-precision sum must fit in a `usize`.

src/libstd/io/buffered.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<R: Seek> Seek for BufReader<R> {
263263
/// See `std::io::Seek` for more details.
264264
///
265265
/// Note: In the edge case where you're seeking with `SeekFrom::Current(n)`
266-
/// where `n` minus the internal buffer length underflows an `i64`, two
266+
/// where `n` minus the internal buffer length overflows an `i64`, two
267267
/// seeks will be performed instead of one. If the second seek returns
268268
/// `Err`, the underlying reader will be left at the same position it would
269269
/// have if you seeked to `SeekFrom::Current(0)`.

src/libstd/time/duration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl Duration {
290290
}
291291

292292
/// Checked `Duration` subtraction. Computes `self - other`, returning [`None`]
293-
/// if the result would be negative or if underflow occurred.
293+
/// if the result would be negative or if overflow occurred.
294294
///
295295
/// [`None`]: ../../std/option/enum.Option.html#variant.None
296296
///

0 commit comments

Comments
 (0)