From 4adab9f63cd1d7a039e799f2b532926cb9bb2cca Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Sun, 29 Mar 2026 16:40:02 +0200 Subject: [PATCH] Make from_bits and as_native_float public Expose these two methods to enable custom float format encode/decode for user-defined Semantics without reimplementing IEEE 754 bit packing. --- src/cast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cast.rs b/src/cast.rs index 6774b39..ee0b38f 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -157,7 +157,7 @@ impl Float { } } - fn from_bits(sem: Semantics, float: u64) -> Self { + pub fn from_bits(sem: Semantics, float: u64) -> Self { // Extract the biased exponent (wipe the sign and mantissa). let biased_exp = ((float >> sem.get_mantissa_len()) & mask(sem.get_exponent_len()) as u64) @@ -225,7 +225,7 @@ impl Float { self.cast_with_rm(to, self.get_rounding_mode()) } - fn as_native_float(&self) -> u64 { + pub fn as_native_float(&self) -> u64 { // https://en.wikipedia.org/wiki/IEEE_754 let mantissa: u64; let mut exp: u64;