@@ -216,8 +216,21 @@ impl f16 {
216
216
pub const MAX_10_EXP : i32 = 4 ;
217
217
218
218
/// Returns `true` if this value is NaN.
219
+ ///
220
+ /// ```
221
+ /// #![feature(f16)]
222
+ /// # #[cfg(target_arch = "x86_64")] { // FIXME(f16_f128): remove when ABI bugs are fixed
223
+ ///
224
+ /// let nan = f16::NAN;
225
+ /// let f = 7.0_f16;
226
+ ///
227
+ /// assert!(nan.is_nan());
228
+ /// assert!(!f.is_nan());
229
+ /// # }
230
+ /// ```
219
231
#[ inline]
220
232
#[ must_use]
233
+ #[ cfg( not( bootstrap) ) ]
221
234
#[ unstable( feature = "f16" , issue = "116909" ) ]
222
235
#[ allow( clippy:: eq_op) ] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
223
236
pub const fn is_nan ( self ) -> bool {
@@ -229,7 +242,7 @@ impl f16 {
229
242
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
230
243
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
231
244
/// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
232
- /// See [explanation of NaN as a special value](f32 ) for more info.
245
+ /// See [explanation of NaN as a special value](f16 ) for more info.
233
246
///
234
247
/// ```
235
248
/// #![feature(f16)]
@@ -252,7 +265,7 @@ impl f16 {
252
265
/// meaning to the sign bit in case of a NaN, and as Rust doesn't guarantee that
253
266
/// the bit pattern of NaNs are conserved over arithmetic operations, the result of
254
267
/// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
255
- /// See [explanation of NaN as a special value](f32 ) for more info.
268
+ /// See [explanation of NaN as a special value](f16 ) for more info.
256
269
///
257
270
/// ```
258
271
/// #![feature(f16)]
@@ -282,6 +295,16 @@ impl f16 {
282
295
///
283
296
/// Note that this function is distinct from `as` casting, which attempts to
284
297
/// preserve the *numeric* value, and not the bitwise value.
298
+ ///
299
+ /// ```
300
+ /// #![feature(f16)]
301
+ /// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
302
+ ///
303
+ /// # // FIXME(f16_f128): enable this once const casting works
304
+ /// # // assert_ne!((1f16).to_bits(), 1f16 as u128); // to_bits() is not casting!
305
+ /// assert_eq!((12.5f16).to_bits(), 0x4a40);
306
+ /// # }
307
+ /// ```
285
308
#[ inline]
286
309
#[ unstable( feature = "f16" , issue = "116909" ) ]
287
310
#[ must_use = "this returns the result of the operation, without modifying the original" ]
@@ -321,6 +344,15 @@ impl f16 {
321
344
///
322
345
/// Note that this function is distinct from `as` casting, which attempts to
323
346
/// preserve the *numeric* value, and not the bitwise value.
347
+ ///
348
+ /// ```
349
+ /// #![feature(f16)]
350
+ /// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
351
+ ///
352
+ /// let v = f16::from_bits(0x4a40);
353
+ /// assert_eq!(v, 12.5);
354
+ /// # }
355
+ /// ```
324
356
#[ inline]
325
357
#[ must_use]
326
358
#[ unstable( feature = "f16" , issue = "116909" ) ]
0 commit comments