Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add “Examples” section header in f32/f64 doc comments. #50720

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ impl f32 {

/// Returns the largest integer less than or equal to a number.
///
/// # Examples
///
/// ```
/// let f = 3.99_f32;
/// let g = 3.0_f32;
Expand Down Expand Up @@ -80,6 +82,8 @@ impl f32 {

/// Returns the smallest integer greater than or equal to a number.
///
/// # Examples
///
/// ```
/// let f = 3.01_f32;
/// let g = 4.0_f32;
Expand All @@ -100,6 +104,8 @@ impl f32 {
/// Returns the nearest integer to a number. Round half-way cases away from
/// `0.0`.
///
/// # Examples
///
/// ```
/// let f = 3.3_f32;
/// let g = -3.3_f32;
Expand All @@ -115,6 +121,8 @@ impl f32 {

/// Returns the integer part of a number.
///
/// # Examples
///
/// ```
/// let f = 3.3_f32;
/// let g = -3.7_f32;
Expand All @@ -130,6 +138,8 @@ impl f32 {

/// Returns the fractional part of a number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -148,6 +158,8 @@ impl f32 {
/// Computes the absolute value of `self`. Returns `NAN` if the
/// number is `NAN`.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -174,6 +186,8 @@ impl f32 {
/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
/// - `NAN` if the number is `NAN`
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -200,6 +214,8 @@ impl f32 {
/// Using `mul_add` can be more performant than an unfused multiply-add if
/// the target architecture has a dedicated `fma` CPU instruction.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -225,6 +241,8 @@ impl f32 {
/// In other words, the result is `self / rhs` rounded to the integer `n`
/// such that `self >= n * rhs`.
///
/// # Examples
///
/// ```
/// #![feature(euclidean_division)]
/// let a: f32 = 7.0;
Expand All @@ -248,6 +266,8 @@ impl f32 {
///
/// In particular, the result `n` satisfies `0 <= n < rhs.abs()`.
///
/// # Examples
///
/// ```
/// #![feature(euclidean_division)]
/// let a: f32 = 7.0;
Expand All @@ -273,6 +293,8 @@ impl f32 {
///
/// Using this function is generally faster than using `powf`
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -289,6 +311,8 @@ impl f32 {

/// Raises a number to a floating point power.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -311,6 +335,8 @@ impl f32 {
///
/// Returns NaN if `self` is a negative number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -334,6 +360,8 @@ impl f32 {

/// Returns `e^(self)`, (the exponential function).
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -358,6 +386,8 @@ impl f32 {

/// Returns `2^(self)`.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -376,6 +406,8 @@ impl f32 {

/// Returns the natural logarithm of the number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand Down Expand Up @@ -404,6 +436,8 @@ impl f32 {
/// `self.log2()` can produce more accurate results for base 2, and
/// `self.log10()` can produce more accurate results for base 10.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -420,6 +454,8 @@ impl f32 {

/// Returns the base 2 logarithm of the number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -441,6 +477,8 @@ impl f32 {

/// Returns the base 10 logarithm of the number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -466,6 +504,8 @@ impl f32 {
/// * If `self <= other`: `0:0`
/// * Else: `self - other`
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand Down Expand Up @@ -493,6 +533,8 @@ impl f32 {

/// Takes the cubic root of a number.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -512,6 +554,8 @@ impl f32 {
/// Calculates the length of the hypotenuse of a right-angle triangle given
/// legs of length `x` and `y`.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -531,6 +575,8 @@ impl f32 {

/// Computes the sine of a number (in radians).
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -552,6 +598,8 @@ impl f32 {

/// Computes the cosine of a number (in radians).
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -573,6 +621,8 @@ impl f32 {

/// Computes the tangent of a number (in radians).
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -591,6 +641,8 @@ impl f32 {
/// the range [-pi/2, pi/2] or NaN if the number is outside the range
/// [-1, 1].
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -611,6 +663,8 @@ impl f32 {
/// the range [0, pi] or NaN if the number is outside the range
/// [-1, 1].
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -630,6 +684,8 @@ impl f32 {
/// Computes the arctangent of a number. Return value is in radians in the
/// range [-pi/2, pi/2];
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -653,6 +709,8 @@ impl f32 {
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand Down Expand Up @@ -682,6 +740,8 @@ impl f32 {
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
/// `(sin(x), cos(x))`.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -703,6 +763,8 @@ impl f32 {
/// Returns `e^(self) - 1` in a way that is accurate even if the
/// number is close to zero.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -722,6 +784,8 @@ impl f32 {
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
/// the operations were performed separately.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -740,6 +804,8 @@ impl f32 {

/// Hyperbolic sine function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -761,6 +827,8 @@ impl f32 {

/// Hyperbolic cosine function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -782,6 +850,8 @@ impl f32 {

/// Hyperbolic tangent function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -803,6 +873,8 @@ impl f32 {

/// Inverse hyperbolic sine function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -825,6 +897,8 @@ impl f32 {

/// Inverse hyperbolic cosine function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand All @@ -846,6 +920,8 @@ impl f32 {

/// Inverse hyperbolic tangent function.
///
/// # Examples
///
/// ```
/// use std::f32;
///
Expand Down
Loading