Skip to content

Commit

Permalink
Add doctests for f16 and f128 library functions where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed May 16, 2024
1 parent 2d89cee commit a7ca099
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
20 changes: 20 additions & 0 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ impl f128 {
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
/// See [explanation of NaN as a special value](f32) for more info.
///
/// ```
/// #![feature(f128)]
///
/// let f = 7.0_f128;
/// let g = -7.0_f128;
///
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "f128", issue = "116909")]
Expand All @@ -241,6 +251,16 @@ impl f128 {
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
/// See [explanation of NaN as a special value](f32) for more info.
///
/// ```
/// #![feature(f128)]
///
/// let f = 7.0_f128;
/// let g = -7.0_f128;
///
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "f128", issue = "116909")]
Expand Down
20 changes: 20 additions & 0 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ impl f16 {
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
/// See [explanation of NaN as a special value](f32) for more info.
///
/// ```
/// #![feature(f16)]
///
/// let f = 7.0_f16;
/// let g = -7.0_f16;
///
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "f16", issue = "116909")]
Expand All @@ -237,6 +247,16 @@ impl f16 {
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
/// See [explanation of NaN as a special value](f32) for more info.
///
/// ```
/// #![feature(f16)]
///
/// let f = 7.0_f16;
/// let g = -7.0_f16;
///
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "f16", issue = "116909")]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,6 @@ impl f64 {
/// ```
/// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
///
/// ```
#[must_use = "this returns the result of the operation, \
without modifying the original"]
Expand Down

0 comments on commit a7ca099

Please sign in to comment.