Skip to content

Commit e5ea3f2

Browse files
authored
Rollup merge of rust-lang#88713 - falk-hueffner:int-log10-documentation-fixes, r=scottmcm
Improve docs for int_log * Clarify rounding. * Avoid "wrapping" wording. * Omit wrong claim on 0 only being returned in error cases. * Typo fix for one_less_than_next_power_of_two.
2 parents c1cb974 + 138ebd1 commit e5ea3f2

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

library/core/src/num/int_macros.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,8 @@ macro_rules! int_impl {
21992199
}
22002200
}
22012201

2202-
/// Returns the logarithm of the number with respect to an arbitrary base.
2202+
/// Returns the logarithm of the number with respect to an arbitrary base,
2203+
/// rounded down.
22032204
///
22042205
/// This method might not be optimized owing to implementation details;
22052206
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -2208,8 +2209,8 @@ macro_rules! int_impl {
22082209
/// # Panics
22092210
///
22102211
/// When the number is zero, or if the base is not at least 2; it
2211-
/// panics in debug mode and the return value is wrapped to 0 in release
2212-
/// mode (the only situation in which the method can return 0).
2212+
/// panics in debug mode and the return value is 0 in release
2213+
/// mode.
22132214
///
22142215
/// # Examples
22152216
///
@@ -2237,13 +2238,12 @@ macro_rules! int_impl {
22372238
}
22382239
}
22392240

2240-
/// Returns the base 2 logarithm of the number.
2241+
/// Returns the base 2 logarithm of the number, rounded down.
22412242
///
22422243
/// # Panics
22432244
///
22442245
/// When the number is zero it panics in debug mode and the return value
2245-
/// is wrapped to 0 in release mode (the only situation in which the
2246-
/// method can return 0).
2246+
/// is 0 in release mode.
22472247
///
22482248
/// # Examples
22492249
///
@@ -2271,13 +2271,12 @@ macro_rules! int_impl {
22712271
}
22722272
}
22732273

2274-
/// Returns the base 10 logarithm of the number.
2274+
/// Returns the base 10 logarithm of the number, rounded down.
22752275
///
22762276
/// # Panics
22772277
///
22782278
/// When the number is zero it panics in debug mode and the return value
2279-
/// is wrapped to 0 in release mode (the only situation in which the
2280-
/// method can return 0).
2279+
/// is 0 in release mode.
22812280
///
22822281
/// # Example
22832282
///
@@ -2305,7 +2304,8 @@ macro_rules! int_impl {
23052304
}
23062305
}
23072306

2308-
/// Returns the logarithm of the number with respect to an arbitrary base.
2307+
/// Returns the logarithm of the number with respect to an arbitrary base,
2308+
/// rounded down.
23092309
///
23102310
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
23112311
///
@@ -2345,7 +2345,7 @@ macro_rules! int_impl {
23452345
}
23462346
}
23472347

2348-
/// Returns the base 2 logarithm of the number.
2348+
/// Returns the base 2 logarithm of the number, rounded down.
23492349
///
23502350
/// Returns `None` if the number is negative or zero.
23512351
///
@@ -2369,7 +2369,7 @@ macro_rules! int_impl {
23692369
}
23702370
}
23712371

2372-
/// Returns the base 10 logarithm of the number.
2372+
/// Returns the base 10 logarithm of the number, rounded down.
23732373
///
23742374
/// Returns `None` if the number is negative or zero.
23752375
///

library/core/src/num/uint_macros.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,8 @@ macro_rules! uint_impl {
658658
}
659659
}
660660

661-
/// Returns the logarithm of the number with respect to an arbitrary base.
661+
/// Returns the logarithm of the number with respect to an arbitrary base,
662+
/// rounded down.
662663
///
663664
/// This method might not be optimized owing to implementation details;
664665
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -667,8 +668,7 @@ macro_rules! uint_impl {
667668
/// # Panics
668669
///
669670
/// When the number is negative, zero, or if the base is not at least 2;
670-
/// it panics in debug mode and the return value is wrapped to 0 in
671-
/// release mode (the only situation in which the method can return 0).
671+
/// it panics in debug mode and the return value is 0 in release mode.
672672
///
673673
/// # Examples
674674
///
@@ -696,13 +696,12 @@ macro_rules! uint_impl {
696696
}
697697
}
698698

699-
/// Returns the base 2 logarithm of the number.
699+
/// Returns the base 2 logarithm of the number, rounded down.
700700
///
701701
/// # Panics
702702
///
703703
/// When the number is negative or zero it panics in debug mode and
704-
/// the return value is wrapped to 0 in release mode (the only situation in
705-
/// which the method can return 0).
704+
/// the return value is 0 in release mode.
706705
///
707706
/// # Examples
708707
///
@@ -730,13 +729,12 @@ macro_rules! uint_impl {
730729
}
731730
}
732731

733-
/// Returns the base 10 logarithm of the number.
732+
/// Returns the base 10 logarithm of the number, rounded down.
734733
///
735734
/// # Panics
736735
///
737736
/// When the number is negative or zero it panics in debug mode and the
738-
/// return value is wrapped to 0 in release mode (the only situation in
739-
/// which the method can return 0).
737+
/// return value is 0 in release mode.
740738
///
741739
/// # Example
742740
///
@@ -764,7 +762,8 @@ macro_rules! uint_impl {
764762
}
765763
}
766764

767-
/// Returns the logarithm of the number with respect to an arbitrary base.
765+
/// Returns the logarithm of the number with respect to an arbitrary base,
766+
/// rounded down.
768767
///
769768
/// Returns `None` if the number is zero, or if the base is not at least 2.
770769
///
@@ -804,7 +803,7 @@ macro_rules! uint_impl {
804803
}
805804
}
806805

807-
/// Returns the base 2 logarithm of the number.
806+
/// Returns the base 2 logarithm of the number, rounded down.
808807
///
809808
/// Returns `None` if the number is zero.
810809
///
@@ -828,7 +827,7 @@ macro_rules! uint_impl {
828827
}
829828
}
830829

831-
/// Returns the base 10 logarithm of the number.
830+
/// Returns the base 10 logarithm of the number, rounded down.
832831
///
833832
/// Returns `None` if the number is zero.
834833
///
@@ -2120,7 +2119,7 @@ macro_rules! uint_impl {
21202119
/// Returns the smallest power of two greater than or equal to `self`.
21212120
///
21222121
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
2123-
/// `uN`), it panics in debug mode and return value is wrapped to 0 in
2122+
/// `uN`), it panics in debug mode and the return value is wrapped to 0 in
21242123
/// release mode (the only situation in which method can return 0).
21252124
///
21262125
/// # Examples

0 commit comments

Comments
 (0)