Skip to content

Commit dbb3c58

Browse files
authored
Add some more basic docstrings (#352)
* Add docstrings to the tgamma functions * Add docstrings to the lgamma functions * Add docstrings to trunc * Add docstrings to exp10 functions
1 parent 86ccf1b commit dbb3c58

File tree

8 files changed

+14
-0
lines changed

8 files changed

+14
-0
lines changed

libm/src/math/exp10.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const P10: &[f64] = &[
66
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
77
];
88

9+
/// Calculates 10 raised to the power of `x` (f64).
910
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
1011
pub fn exp10(x: f64) -> f64 {
1112
let (mut y, n) = modf(x);

libm/src/math/exp10f.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const LN10_F64: f64 = 3.32192809488736234787031942948939;
55
const P10: &[f32] =
66
&[1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7];
77

8+
/// Calculates 10 raised to the power of `x` (f32).
89
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
910
pub fn exp10f(x: f32) -> f32 {
1011
let (mut y, n) = modff(x);

libm/src/math/lgamma.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use super::lgamma_r;
22

3+
/// The natural logarithm of the
4+
/// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f64).
35
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
46
pub fn lgamma(x: f64) -> f64 {
57
lgamma_r(x).0

libm/src/math/lgammaf.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use super::lgammaf_r;
22

3+
/// The natural logarithm of the
4+
/// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f32).
35
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
46
pub fn lgammaf(x: f32) -> f32 {
57
lgammaf_r(x).0

libm/src/math/tgamma.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ fn s(x: f64) -> f64 {
130130
return num / den;
131131
}
132132

133+
/// The [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f64).
133134
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
134135
pub fn tgamma(mut x: f64) -> f64 {
135136
let u: u64 = x.to_bits();

libm/src/math/tgammaf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::tgamma;
22

3+
/// The [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f32).
34
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
45
pub fn tgammaf(x: f32) -> f32 {
56
tgamma(x as f64) as f32

libm/src/math/trunc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use core::f64;
22

3+
/// Rounds the number toward 0 to the closest integral value (f64).
4+
///
5+
/// This effectively removes the decimal part of the number, leaving the integral part.
36
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
47
pub fn trunc(x: f64) -> f64 {
58
select_implementation! {

libm/src/math/truncf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use core::f32;
22

3+
/// Rounds the number toward 0 to the closest integral value (f32).
4+
///
5+
/// This effectively removes the decimal part of the number, leaving the integral part.
36
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
47
pub fn truncf(x: f32) -> f32 {
58
select_implementation! {

0 commit comments

Comments
 (0)