Skip to content

Commit 138ebd1

Browse files
author
Falk Hüffner
committed
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.
1 parent b2d9bcd commit 138ebd1

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
@@ -2001,7 +2001,8 @@ macro_rules! int_impl {
20012001
}
20022002
}
20032003

2004-
/// Returns the logarithm of the number with respect to an arbitrary base.
2004+
/// Returns the logarithm of the number with respect to an arbitrary base,
2005+
/// rounded down.
20052006
///
20062007
/// This method might not be optimized owing to implementation details;
20072008
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -2010,8 +2011,8 @@ macro_rules! int_impl {
20102011
/// # Panics
20112012
///
20122013
/// When the number is zero, or if the base is not at least 2; it
2013-
/// panics in debug mode and the return value is wrapped to 0 in release
2014-
/// mode (the only situation in which the method can return 0).
2014+
/// panics in debug mode and the return value is 0 in release
2015+
/// mode.
20152016
///
20162017
/// # Examples
20172018
///
@@ -2039,13 +2040,12 @@ macro_rules! int_impl {
20392040
}
20402041
}
20412042

2042-
/// Returns the base 2 logarithm of the number.
2043+
/// Returns the base 2 logarithm of the number, rounded down.
20432044
///
20442045
/// # Panics
20452046
///
20462047
/// When the number is zero it panics in debug mode and the return value
2047-
/// is wrapped to 0 in release mode (the only situation in which the
2048-
/// method can return 0).
2048+
/// is 0 in release mode.
20492049
///
20502050
/// # Examples
20512051
///
@@ -2073,13 +2073,12 @@ macro_rules! int_impl {
20732073
}
20742074
}
20752075

2076-
/// Returns the base 10 logarithm of the number.
2076+
/// Returns the base 10 logarithm of the number, rounded down.
20772077
///
20782078
/// # Panics
20792079
///
20802080
/// When the number is zero it panics in debug mode and the return value
2081-
/// is wrapped to 0 in release mode (the only situation in which the
2082-
/// method can return 0).
2081+
/// is 0 in release mode.
20832082
///
20842083
/// # Example
20852084
///
@@ -2107,7 +2106,8 @@ macro_rules! int_impl {
21072106
}
21082107
}
21092108

2110-
/// Returns the logarithm of the number with respect to an arbitrary base.
2109+
/// Returns the logarithm of the number with respect to an arbitrary base,
2110+
/// rounded down.
21112111
///
21122112
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
21132113
///
@@ -2147,7 +2147,7 @@ macro_rules! int_impl {
21472147
}
21482148
}
21492149

2150-
/// Returns the base 2 logarithm of the number.
2150+
/// Returns the base 2 logarithm of the number, rounded down.
21512151
///
21522152
/// Returns `None` if the number is negative or zero.
21532153
///
@@ -2171,7 +2171,7 @@ macro_rules! int_impl {
21712171
}
21722172
}
21732173

2174-
/// Returns the base 10 logarithm of the number.
2174+
/// Returns the base 10 logarithm of the number, rounded down.
21752175
///
21762176
/// Returns `None` if the number is negative or zero.
21772177
///

library/core/src/num/uint_macros.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ macro_rules! uint_impl {
635635
}
636636
}
637637

638-
/// Returns the logarithm of the number with respect to an arbitrary base.
638+
/// Returns the logarithm of the number with respect to an arbitrary base,
639+
/// rounded down.
639640
///
640641
/// This method might not be optimized owing to implementation details;
641642
/// `log2` can produce results more efficiently for base 2, and `log10`
@@ -644,8 +645,7 @@ macro_rules! uint_impl {
644645
/// # Panics
645646
///
646647
/// When the number is negative, zero, or if the base is not at least 2;
647-
/// it panics in debug mode and the return value is wrapped to 0 in
648-
/// release mode (the only situation in which the method can return 0).
648+
/// it panics in debug mode and the return value is 0 in release mode.
649649
///
650650
/// # Examples
651651
///
@@ -673,13 +673,12 @@ macro_rules! uint_impl {
673673
}
674674
}
675675

676-
/// Returns the base 2 logarithm of the number.
676+
/// Returns the base 2 logarithm of the number, rounded down.
677677
///
678678
/// # Panics
679679
///
680680
/// When the number is negative or zero it panics in debug mode and
681-
/// the return value is wrapped to 0 in release mode (the only situation in
682-
/// which the method can return 0).
681+
/// the return value is 0 in release mode.
683682
///
684683
/// # Examples
685684
///
@@ -707,13 +706,12 @@ macro_rules! uint_impl {
707706
}
708707
}
709708

710-
/// Returns the base 10 logarithm of the number.
709+
/// Returns the base 10 logarithm of the number, rounded down.
711710
///
712711
/// # Panics
713712
///
714713
/// When the number is negative or zero it panics in debug mode and the
715-
/// return value is wrapped to 0 in release mode (the only situation in
716-
/// which the method can return 0).
714+
/// return value is 0 in release mode.
717715
///
718716
/// # Example
719717
///
@@ -741,7 +739,8 @@ macro_rules! uint_impl {
741739
}
742740
}
743741

744-
/// Returns the logarithm of the number with respect to an arbitrary base.
742+
/// Returns the logarithm of the number with respect to an arbitrary base,
743+
/// rounded down.
745744
///
746745
/// Returns `None` if the number is zero, or if the base is not at least 2.
747746
///
@@ -781,7 +780,7 @@ macro_rules! uint_impl {
781780
}
782781
}
783782

784-
/// Returns the base 2 logarithm of the number.
783+
/// Returns the base 2 logarithm of the number, rounded down.
785784
///
786785
/// Returns `None` if the number is zero.
787786
///
@@ -805,7 +804,7 @@ macro_rules! uint_impl {
805804
}
806805
}
807806

808-
/// Returns the base 10 logarithm of the number.
807+
/// Returns the base 10 logarithm of the number, rounded down.
809808
///
810809
/// Returns `None` if the number is zero.
811810
///
@@ -1992,7 +1991,7 @@ macro_rules! uint_impl {
19921991
/// Returns the smallest power of two greater than or equal to `self`.
19931992
///
19941993
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
1995-
/// `uN`), it panics in debug mode and return value is wrapped to 0 in
1994+
/// `uN`), it panics in debug mode and the return value is wrapped to 0 in
19961995
/// release mode (the only situation in which method can return 0).
19971996
///
19981997
/// # Examples

0 commit comments

Comments
 (0)