Skip to content

Commit

Permalink
Revert "chore: use {f32,f64}::from_bits"
Browse files Browse the repository at this point in the history
This reverts commit 6850c05.
  • Loading branch information
LDeakin committed Jan 12, 2025
1 parent 66fbc0b commit a1c1506
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions zarrs_metadata/src/v3/array/nan_representations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
//!
//! Zarr uses the not-a-number (NaN) value where the sign bit is 0 (positive), the most significant bit (MSB) of the mantissa is 1, and all other bits of the mantissa are zero.
use std::mem::transmute;

use half::{bf16, f16};

// https://github.com/rust-lang/rust/issues/72447

/// The Zarr "NaN" fill value for a 64-bit IEEE 754 floating point number.
#[allow(clippy::unusual_byte_groupings)]
pub const ZARR_NAN_F64: f64 =
f64::from_bits(0b0_11111111111_1000000000000000000000000000000000000000000000000000);
pub const ZARR_NAN_F64: f64 = unsafe {
transmute::<u64, f64>(0b0_11111111111_1000000000000000000000000000000000000000000000000000)
};
// const ZARR_NAN_F64: f64 = f64::from_bits(0b0_11111111111_1000000000000000000000000000000000000000000000000000);

/// The Zarr "NaN" fill value for a 32-bit IEEE 754 floating point number.
#[allow(clippy::unusual_byte_groupings)]
pub const ZARR_NAN_F32: f32 = f32::from_bits(0b0_11111111_10000000000000000000000);
pub const ZARR_NAN_F32: f32 =
unsafe { transmute::<u32, f32>(0b0_11111111_10000000000000000000000) };
// const ZARR_NAN_F32: f32 = f32::from_bits(0b0_11111111_10000000000000000000000);

/// The Zarr "NaN" fill value for a 16-bit IEEE 754 floating point number.
pub const ZARR_NAN_F16: f16 = f16::NAN;
Expand Down

0 comments on commit a1c1506

Please sign in to comment.