@@ -19,9 +19,91 @@ pub mod consts {}
1919
2020#[ cfg( not( test) ) ]
2121impl f16 {
22- // FIXME(f16_f128): almost everything in this `impl` is missing examples and a const
22+ // FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
2323 // implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.
2424
25+ /// The radix or base of the internal representation of `f16`.
26+ #[ unstable( feature = "f16" , issue = "116909" ) ]
27+ pub const RADIX : u32 = 2 ;
28+
29+ /// Number of significant digits in base 2.
30+ #[ unstable( feature = "f16" , issue = "116909" ) ]
31+ pub const MANTISSA_DIGITS : u32 = 11 ;
32+
33+ /// Approximate number of significant digits in base 10.
34+ ///
35+ /// This is the maximum <i>x</i> such that any decimal number with <i>x</i>
36+ /// significant digits can be converted to `f16` and back without loss.
37+ ///
38+ /// Equal to floor(log<sub>10</sub> 2<sup>[`MANTISSA_DIGITS`] − 1</sup>).
39+ ///
40+ /// [`MANTISSA_DIGITS`]: f16::MANTISSA_DIGITS
41+ #[ unstable( feature = "f16" , issue = "116909" ) ]
42+ pub const DIGITS : u32 = 3 ;
43+
44+ /// [Machine epsilon] value for `f16`.
45+ ///
46+ /// This is the difference between `1.0` and the next larger representable number.
47+ ///
48+ /// Equal to 2<sup>1 − [`MANTISSA_DIGITS`]</sup>.
49+ ///
50+ /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
51+ /// [`MANTISSA_DIGITS`]: f16::MANTISSA_DIGITS
52+ #[ unstable( feature = "f16" , issue = "116909" ) ]
53+ pub const EPSILON : f16 = 9.7656e-4_f16 ;
54+
55+ /// Smallest finite `f16` value.
56+ ///
57+ /// Equal to −[`MAX`].
58+ ///
59+ /// [`MAX`]: f16::MAX
60+ #[ unstable( feature = "f16" , issue = "116909" ) ]
61+ pub const MIN : f16 = -6.5504e+4_f16 ;
62+ /// Smallest positive normal `f16` value.
63+ ///
64+ /// Equal to 2<sup>[`MIN_EXP`] − 1</sup>.
65+ ///
66+ /// [`MIN_EXP`]: f16::MIN_EXP
67+ #[ unstable( feature = "f16" , issue = "116909" ) ]
68+ pub const MIN_POSITIVE : f16 = 6.1035e-5_f16 ;
69+ /// Largest finite `f16` value.
70+ ///
71+ /// Equal to
72+ /// (1 − 2<sup>−[`MANTISSA_DIGITS`]</sup>) 2<sup>[`MAX_EXP`]</sup>.
73+ ///
74+ /// [`MANTISSA_DIGITS`]: f16::MANTISSA_DIGITS
75+ /// [`MAX_EXP`]: f16::MAX_EXP
76+ #[ unstable( feature = "f16" , issue = "116909" ) ]
77+ pub const MAX : f16 = 6.5504e+4_f16 ;
78+
79+ /// One greater than the minimum possible normal power of 2 exponent.
80+ ///
81+ /// If <i>x</i> = `MIN_EXP`, then normal numbers
82+ /// ≥ 0.5 × 2<sup><i>x</i></sup>.
83+ #[ unstable( feature = "f16" , issue = "116909" ) ]
84+ pub const MIN_EXP : i32 = -13 ;
85+ /// Maximum possible power of 2 exponent.
86+ ///
87+ /// If <i>x</i> = `MAX_EXP`, then normal numbers
88+ /// < 1 × 2<sup><i>x</i></sup>.
89+ #[ unstable( feature = "f16" , issue = "116909" ) ]
90+ pub const MAX_EXP : i32 = 16 ;
91+
92+ /// Minimum <i>x</i> for which 10<sup><i>x</i></sup> is normal.
93+ ///
94+ /// Equal to ceil(log<sub>10</sub> [`MIN_POSITIVE`]).
95+ ///
96+ /// [`MIN_POSITIVE`]: f16::MIN_POSITIVE
97+ #[ unstable( feature = "f16" , issue = "116909" ) ]
98+ pub const MIN_10_EXP : i32 = -4 ;
99+ /// Maximum <i>x</i> for which 10<sup><i>x</i></sup> is normal.
100+ ///
101+ /// Equal to floor(log<sub>10</sub> [`MAX`]).
102+ ///
103+ /// [`MAX`]: f16::MAX
104+ #[ unstable( feature = "f16" , issue = "116909" ) ]
105+ pub const MAX_10_EXP : i32 = 4 ;
106+
25107 /// Returns `true` if this value is NaN.
26108 #[ inline]
27109 #[ must_use]
0 commit comments