11
11
//! Numeric traits and functions for generic mathematics
12
12
//!
13
13
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14
- //! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float }`.
14
+ //! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
15
15
16
16
#![ allow( missing_doc) ]
17
17
@@ -97,7 +97,7 @@ pub trait One: Mul<Self, Self> {
97
97
pub trait Signed : Num + Neg < Self > {
98
98
/// Computes the absolute value.
99
99
///
100
- /// For float, f32, and f64, `NaN` will be returned if the number is `NaN`.
100
+ /// For ` f32` and ` f64` , `NaN` will be returned if the number is `NaN`.
101
101
fn abs ( & self ) -> Self ;
102
102
103
103
/// The positive difference of two numbers.
@@ -108,15 +108,17 @@ pub trait Signed: Num + Neg<Self> {
108
108
109
109
/// Returns the sign of the number.
110
110
///
111
- /// For `float`, `f32`, `f64`:
112
- /// * `1.0` if the number is positive, `+0.0` or `INFINITY`
113
- /// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
114
- /// * `NaN` if the number is `NaN`
111
+ /// For `f32` and `f64`:
112
+ ///
113
+ /// * `1.0` if the number is positive, `+0.0` or `INFINITY`
114
+ /// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
115
+ /// * `NaN` if the number is `NaN`
115
116
///
116
117
/// For `int`:
117
- /// * `0` if the number is zero
118
- /// * `1` if the number is positive
119
- /// * `-1` if the number is negative
118
+ ///
119
+ /// * `0` if the number is zero
120
+ /// * `1` if the number is positive
121
+ /// * `-1` if the number is negative
120
122
fn signum ( & self ) -> Self ;
121
123
122
124
/// Returns true if the number is positive and false if the number is zero or negative.
@@ -128,7 +130,7 @@ pub trait Signed: Num + Neg<Self> {
128
130
129
131
/// Computes the absolute value.
130
132
///
131
- /// For float, f32, and f64, `NaN` will be returned if the number is `NaN`
133
+ /// For ` f32` and ` f64` , `NaN` will be returned if the number is `NaN`
132
134
#[ inline( always) ]
133
135
pub fn abs < T : Signed > ( value : T ) -> T {
134
136
value. abs ( )
@@ -145,15 +147,17 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
145
147
146
148
/// Returns the sign of the number.
147
149
///
148
- /// For float, f32, f64:
149
- /// - `1.0` if the number is positive, `+0.0` or `INFINITY`
150
- /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
151
- /// - `NAN` if the number is `NAN`
150
+ /// For `f32` and `f64`:
151
+ ///
152
+ /// * `1.0` if the number is positive, `+0.0` or `INFINITY`
153
+ /// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
154
+ /// * `NaN` if the number is `NaN`
152
155
///
153
156
/// For int:
154
- /// - `0` if the number is zero
155
- /// - `1` if the number is positive
156
- /// - `-1` if the number is negative
157
+ ///
158
+ /// * `0` if the number is zero
159
+ /// * `1` if the number is positive
160
+ /// * `-1` if the number is negative
157
161
#[ inline( always) ] pub fn signum < T : Signed > ( value : T ) -> T { value. signum ( ) }
158
162
159
163
/// A trait for values which cannot be negative
0 commit comments