Skip to content

Commit 8f57068

Browse files
committed
Add doctests for f16 and f128 library functions where possible
1 parent 266f7a3 commit 8f57068

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

core/src/num/f128.rs

+20
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ impl f128 {
228228
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
229229
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
230230
/// See [explanation of NaN as a special value](f32) for more info.
231+
///
232+
/// ```
233+
/// #![feature(f128)]
234+
///
235+
/// let f = 7.0_f128;
236+
/// let g = -7.0_f128;
237+
///
238+
/// assert!(f.is_sign_positive());
239+
/// assert!(!g.is_sign_positive());
240+
/// ```
231241
#[inline]
232242
#[must_use]
233243
#[unstable(feature = "f128", issue = "116909")]
@@ -241,6 +251,16 @@ impl f128 {
241251
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
242252
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
243253
/// See [explanation of NaN as a special value](f32) for more info.
254+
///
255+
/// ```
256+
/// #![feature(f128)]
257+
///
258+
/// let f = 7.0_f128;
259+
/// let g = -7.0_f128;
260+
///
261+
/// assert!(!f.is_sign_negative());
262+
/// assert!(g.is_sign_negative());
263+
/// ```
244264
#[inline]
245265
#[must_use]
246266
#[unstable(feature = "f128", issue = "116909")]

core/src/num/f16.rs

+20
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ impl f16 {
224224
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
225225
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
226226
/// See [explanation of NaN as a special value](f32) for more info.
227+
///
228+
/// ```
229+
/// #![feature(f16)]
230+
///
231+
/// let f = 7.0_f16;
232+
/// let g = -7.0_f16;
233+
///
234+
/// assert!(f.is_sign_positive());
235+
/// assert!(!g.is_sign_positive());
236+
/// ```
227237
#[inline]
228238
#[must_use]
229239
#[unstable(feature = "f16", issue = "116909")]
@@ -237,6 +247,16 @@ impl f16 {
237247
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
238248
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
239249
/// See [explanation of NaN as a special value](f32) for more info.
250+
///
251+
/// ```
252+
/// #![feature(f16)]
253+
///
254+
/// let f = 7.0_f16;
255+
/// let g = -7.0_f16;
256+
///
257+
/// assert!(!f.is_sign_negative());
258+
/// assert!(g.is_sign_negative());
259+
/// ```
240260
#[inline]
241261
#[must_use]
242262
#[unstable(feature = "f16", issue = "116909")]

core/src/num/f64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,6 @@ impl f64 {
11111111
/// ```
11121112
/// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
11131113
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1114-
///
11151114
/// ```
11161115
#[must_use = "this returns the result of the operation, \
11171116
without modifying the original"]

0 commit comments

Comments
 (0)