Skip to content

Commit c00bced

Browse files
committed
disambiguate docs from new primitive
1 parent d02f32e commit c00bced

File tree

6 files changed

+134
-133
lines changed

6 files changed

+134
-133
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
* `rand_distr` 0.4 -> 0.5
1212
* `rkyv` 0.7 -> 0.8
1313
* (dev) `criterion` 0.4 -> 0.5
14+
- Minimum supported Rust version has been changed to 1.81 due to above dependency updates.
1415

1516
### Added
1617
- Added support for `arbitrary` crate. Fixes [#110]. By [@FL33TW00D].

src/bfloat.rs

+53-53
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pub(crate) mod convert;
2727
/// A 16-bit floating point type implementing the [`bfloat16`] format.
2828
///
2929
/// The [`bfloat16`] floating point format is a truncated 16-bit version of the IEEE 754 standard
30-
/// `binary32`, a.k.a [`f32`]. [`bf16`] has approximately the same dynamic range as [`f32`] by
31-
/// having a lower precision than [`f16`][crate::f16]. While [`f16`][crate::f16] has a precision of
32-
/// 11 bits, [`bf16`] has a precision of only 8 bits.
30+
/// `binary32`, a.k.a [`f32`]. [`struct@bf16`] has approximately the same dynamic range as [`f32`] by
31+
/// having a lower precision than [`struct@f16`][crate::f16]. While [`struct@f16`][crate::f16] has a precision of
32+
/// 11 bits, [`struct@bf16`] has a precision of only 8 bits.
3333
///
3434
/// [`bfloat16`]: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
3535
#[allow(non_camel_case_types)]
@@ -47,14 +47,14 @@ pub(crate) mod convert;
4747
pub struct bf16(u16);
4848

4949
impl bf16 {
50-
/// Constructs a [`bf16`] value from the raw bits.
50+
/// Constructs a [`struct@bf16`] value from the raw bits.
5151
#[inline]
5252
#[must_use]
5353
pub const fn from_bits(bits: u16) -> bf16 {
5454
bf16(bits)
5555
}
5656

57-
/// Constructs a [`bf16`] value from a 32-bit floating point value.
57+
/// Constructs a [`struct@bf16`] value from a 32-bit floating point value.
5858
///
5959
/// This operation is lossy. If the 32-bit value is too large to fit, ±∞ will result. NaN values
6060
/// are preserved. Subnormal values that are too tiny to be represented will result in ±0. All
@@ -65,7 +65,7 @@ impl bf16 {
6565
Self::from_f32_const(value)
6666
}
6767

68-
/// Constructs a [`bf16`] value from a 32-bit floating point value.
68+
/// Constructs a [`struct@bf16`] value from a 32-bit floating point value.
6969
///
7070
/// This function is identical to [`from_f32`][Self::from_f32] except it never uses hardware
7171
/// intrinsics, which allows it to be `const`. [`from_f32`][Self::from_f32] should be preferred
@@ -80,7 +80,7 @@ impl bf16 {
8080
bf16(convert::f32_to_bf16(value))
8181
}
8282

83-
/// Constructs a [`bf16`] value from a 64-bit floating point value.
83+
/// Constructs a [`struct@bf16`] value from a 64-bit floating point value.
8484
///
8585
/// This operation is lossy. If the 64-bit value is to large to fit, ±∞ will result. NaN values
8686
/// are preserved. 64-bit subnormal values are too tiny to be represented and result in ±0.
@@ -92,7 +92,7 @@ impl bf16 {
9292
Self::from_f64_const(value)
9393
}
9494

95-
/// Constructs a [`bf16`] value from a 64-bit floating point value.
95+
/// Constructs a [`struct@bf16`] value from a 64-bit floating point value.
9696
///
9797
/// This function is identical to [`from_f64`][Self::from_f64] except it never uses hardware
9898
/// intrinsics, which allows it to be `const`. [`from_f64`][Self::from_f64] should be preferred
@@ -108,7 +108,7 @@ impl bf16 {
108108
bf16(convert::f64_to_bf16(value))
109109
}
110110

111-
/// Converts a [`bf16`] into the underlying bit representation.
111+
/// Converts a [`struct@bf16`] into the underlying bit representation.
112112
#[inline]
113113
#[must_use]
114114
pub const fn to_bits(self) -> u16 {
@@ -224,7 +224,7 @@ impl bf16 {
224224
bf16::from_bits(u16::from_ne_bytes(bytes))
225225
}
226226

227-
/// Converts a [`bf16`] value into an [`f32`] value.
227+
/// Converts a [`struct@bf16`] value into an [`f32`] value.
228228
///
229229
/// This conversion is lossless as all values can be represented exactly in [`f32`].
230230
#[inline]
@@ -233,7 +233,7 @@ impl bf16 {
233233
self.to_f32_const()
234234
}
235235

236-
/// Converts a [`bf16`] value into an [`f32`] value.
236+
/// Converts a [`struct@bf16`] value into an [`f32`] value.
237237
///
238238
/// This function is identical to [`to_f32`][Self::to_f32] except it never uses hardware
239239
/// intrinsics, which allows it to be `const`. [`to_f32`][Self::to_f32] should be preferred
@@ -246,7 +246,7 @@ impl bf16 {
246246
convert::bf16_to_f32(self.0)
247247
}
248248

249-
/// Converts a [`bf16`] value into an [`f64`] value.
249+
/// Converts a [`struct@bf16`] value into an [`f64`] value.
250250
///
251251
/// This conversion is lossless as all values can be represented exactly in [`f64`].
252252
#[inline]
@@ -255,7 +255,7 @@ impl bf16 {
255255
self.to_f64_const()
256256
}
257257

258-
/// Converts a [`bf16`] value into an [`f64`] value.
258+
/// Converts a [`struct@bf16`] value into an [`f64`] value.
259259
///
260260
/// This function is identical to [`to_f64`][Self::to_f64] except it never uses hardware
261261
/// intrinsics, which allows it to be `const`. [`to_f64`][Self::to_f64] should be preferred
@@ -649,7 +649,7 @@ impl bf16 {
649649

650650
/// Alternate serialize adapter for serializing as a float.
651651
///
652-
/// By default, [`bf16`] serializes as a newtype of [`u16`]. This is an alternate serialize
652+
/// By default, [`struct@bf16`] serializes as a newtype of [`u16`]. This is an alternate serialize
653653
/// implementation that serializes as an [`f32`] value. It is designed for use with
654654
/// `serialize_with` serde attributes. Deserialization from `f32` values is already supported by
655655
/// the default deserialize implementation.
@@ -675,7 +675,7 @@ impl bf16 {
675675

676676
/// Alternate serialize adapter for serializing as a string.
677677
///
678-
/// By default, [`bf16`] serializes as a newtype of [`u16`]. This is an alternate serialize
678+
/// By default, [`struct@bf16`] serializes as a newtype of [`u16`]. This is an alternate serialize
679679
/// implementation that serializes as a string value. It is designed for use with
680680
/// `serialize_with` serde attributes. Deserialization from string values is already supported
681681
/// by the default deserialize implementation.
@@ -702,87 +702,87 @@ impl bf16 {
702702
serializer.serialize_str(&self.to_string())
703703
}
704704

705-
/// Approximate number of [`bf16`] significant digits in base 10
705+
/// Approximate number of [`struct@bf16`] significant digits in base 10
706706
pub const DIGITS: u32 = 2;
707-
/// [`bf16`]
707+
/// [`struct@bf16`]
708708
/// [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon) value
709709
///
710710
/// This is the difference between 1.0 and the next largest representable number.
711711
pub const EPSILON: bf16 = bf16(0x3C00u16);
712-
/// [`bf16`] positive Infinity (+∞)
712+
/// [`struct@bf16`] positive Infinity (+∞)
713713
pub const INFINITY: bf16 = bf16(0x7F80u16);
714-
/// Number of [`bf16`] significant digits in base 2
714+
/// Number of [`struct@bf16`] significant digits in base 2
715715
pub const MANTISSA_DIGITS: u32 = 8;
716-
/// Largest finite [`bf16`] value
716+
/// Largest finite [`struct@bf16`] value
717717
pub const MAX: bf16 = bf16(0x7F7F);
718-
/// Maximum possible [`bf16`] power of 10 exponent
718+
/// Maximum possible [`struct@bf16`] power of 10 exponent
719719
pub const MAX_10_EXP: i32 = 38;
720-
/// Maximum possible [`bf16`] power of 2 exponent
720+
/// Maximum possible [`struct@bf16`] power of 2 exponent
721721
pub const MAX_EXP: i32 = 128;
722-
/// Smallest finite [`bf16`] value
722+
/// Smallest finite [`struct@bf16`] value
723723
pub const MIN: bf16 = bf16(0xFF7F);
724-
/// Minimum possible normal [`bf16`] power of 10 exponent
724+
/// Minimum possible normal [`struct@bf16`] power of 10 exponent
725725
pub const MIN_10_EXP: i32 = -37;
726-
/// One greater than the minimum possible normal [`bf16`] power of 2 exponent
726+
/// One greater than the minimum possible normal [`struct@bf16`] power of 2 exponent
727727
pub const MIN_EXP: i32 = -125;
728-
/// Smallest positive normal [`bf16`] value
728+
/// Smallest positive normal [`struct@bf16`] value
729729
pub const MIN_POSITIVE: bf16 = bf16(0x0080u16);
730-
/// [`bf16`] Not a Number (NaN)
730+
/// [`struct@bf16`] Not a Number (NaN)
731731
pub const NAN: bf16 = bf16(0x7FC0u16);
732-
/// [`bf16`] negative infinity (-∞).
732+
/// [`struct@bf16`] negative infinity (-∞).
733733
pub const NEG_INFINITY: bf16 = bf16(0xFF80u16);
734-
/// The radix or base of the internal representation of [`bf16`]
734+
/// The radix or base of the internal representation of [`struct@bf16`]
735735
pub const RADIX: u32 = 2;
736736

737-
/// Minimum positive subnormal [`bf16`] value
737+
/// Minimum positive subnormal [`struct@bf16`] value
738738
pub const MIN_POSITIVE_SUBNORMAL: bf16 = bf16(0x0001u16);
739-
/// Maximum subnormal [`bf16`] value
739+
/// Maximum subnormal [`struct@bf16`] value
740740
pub const MAX_SUBNORMAL: bf16 = bf16(0x007Fu16);
741741

742-
/// [`bf16`] 1
742+
/// [`struct@bf16`] 1
743743
pub const ONE: bf16 = bf16(0x3F80u16);
744-
/// [`bf16`] 0
744+
/// [`struct@bf16`] 0
745745
pub const ZERO: bf16 = bf16(0x0000u16);
746-
/// [`bf16`] -0
746+
/// [`struct@bf16`] -0
747747
pub const NEG_ZERO: bf16 = bf16(0x8000u16);
748-
/// [`bf16`] -1
748+
/// [`struct@bf16`] -1
749749
pub const NEG_ONE: bf16 = bf16(0xBF80u16);
750750

751-
/// [`bf16`] Euler's number (ℯ)
751+
/// [`struct@bf16`] Euler's number (ℯ)
752752
pub const E: bf16 = bf16(0x402Eu16);
753-
/// [`bf16`] Archimedes' constant (π)
753+
/// [`struct@bf16`] Archimedes' constant (π)
754754
pub const PI: bf16 = bf16(0x4049u16);
755-
/// [`bf16`] 1/π
755+
/// [`struct@bf16`] 1/π
756756
pub const FRAC_1_PI: bf16 = bf16(0x3EA3u16);
757-
/// [`bf16`] 1/√2
757+
/// [`struct@bf16`] 1/√2
758758
pub const FRAC_1_SQRT_2: bf16 = bf16(0x3F35u16);
759-
/// [`bf16`] 2/π
759+
/// [`struct@bf16`] 2/π
760760
pub const FRAC_2_PI: bf16 = bf16(0x3F23u16);
761-
/// [`bf16`] 2/√π
761+
/// [`struct@bf16`] 2/√π
762762
pub const FRAC_2_SQRT_PI: bf16 = bf16(0x3F90u16);
763-
/// [`bf16`] π/2
763+
/// [`struct@bf16`] π/2
764764
pub const FRAC_PI_2: bf16 = bf16(0x3FC9u16);
765-
/// [`bf16`] π/3
765+
/// [`struct@bf16`] π/3
766766
pub const FRAC_PI_3: bf16 = bf16(0x3F86u16);
767-
/// [`bf16`] π/4
767+
/// [`struct@bf16`] π/4
768768
pub const FRAC_PI_4: bf16 = bf16(0x3F49u16);
769-
/// [`bf16`] π/6
769+
/// [`struct@bf16`] π/6
770770
pub const FRAC_PI_6: bf16 = bf16(0x3F06u16);
771-
/// [`bf16`] π/8
771+
/// [`struct@bf16`] π/8
772772
pub const FRAC_PI_8: bf16 = bf16(0x3EC9u16);
773-
/// [`bf16`] 𝗅𝗇 10
773+
/// [`struct@bf16`] 𝗅𝗇 10
774774
pub const LN_10: bf16 = bf16(0x4013u16);
775-
/// [`bf16`] 𝗅𝗇 2
775+
/// [`struct@bf16`] 𝗅𝗇 2
776776
pub const LN_2: bf16 = bf16(0x3F31u16);
777-
/// [`bf16`] 𝗅𝗈𝗀₁₀ℯ
777+
/// [`struct@bf16`] 𝗅𝗈𝗀₁₀ℯ
778778
pub const LOG10_E: bf16 = bf16(0x3EDEu16);
779-
/// [`bf16`] 𝗅𝗈𝗀₁₀2
779+
/// [`struct@bf16`] 𝗅𝗈𝗀₁₀2
780780
pub const LOG10_2: bf16 = bf16(0x3E9Au16);
781-
/// [`bf16`] 𝗅𝗈𝗀₂ℯ
781+
/// [`struct@bf16`] 𝗅𝗈𝗀₂ℯ
782782
pub const LOG2_E: bf16 = bf16(0x3FB9u16);
783-
/// [`bf16`] 𝗅𝗈𝗀₂10
783+
/// [`struct@bf16`] 𝗅𝗈𝗀₂10
784784
pub const LOG2_10: bf16 = bf16(0x4055u16);
785-
/// [`bf16`] √2
785+
/// [`struct@bf16`] √2
786786
pub const SQRT_2: bf16 = bf16(0x3FB5u16);
787787
}
788788

0 commit comments

Comments
 (0)