pub struct PrecisionBound { /* private fields */ }Expand description
Precision bound calculator for floating-point values.
Given a precision tolerance (e.g., 0.00005 for 4 decimal places), this struct computes the minimum bits needed to represent values within that tolerance, and provides methods to convert floats to their fixed-point representation.
Implementations§
Source§impl PrecisionBound
impl PrecisionBound
Sourcepub fn precision_bound(&mut self, orig: f64) -> f64
pub fn precision_bound(&mut self, orig: f64) -> f64
Compute the precision-bounded representation of a float.
This finds the minimum precision representation of orig that
is within the precision tolerance.
Sourcepub fn cal_length(&mut self, x: f64)
pub fn cal_length(&mut self, x: f64)
Calculate and update the required bit lengths for a precision-bounded value.
Sourcepub fn get_length(&self) -> (u64, u64)
pub fn get_length(&self) -> (u64, u64)
Get the computed integer and decimal bit lengths.
Sourcepub fn set_length(&mut self, ilen: u64, dlen: u64)
pub fn set_length(&mut self, ilen: u64, dlen: u64)
Set the integer and decimal bit lengths manually.
Sourcepub fn fetch_components(&self, bd: f64) -> (i64, u64)
pub fn fetch_components(&self, bd: f64) -> (i64, u64)
Fetch the integer and decimal components of a precision-bounded float.
Sourcepub fn fetch_fixed_aligned(&self, bd: f64) -> i64
pub fn fetch_fixed_aligned(&self, bd: f64) -> i64
Fetch the byte-aligned fixed-point representation.
This converts a float to its fixed-point representation suitable for byte-sliced storage.
Sourcepub fn is_bounded(&self, a: f64, b: f64) -> bool
pub fn is_bounded(&self, a: f64, b: f64) -> bool
Check if two values are within the precision tolerance.
Trait Implementations§
Source§impl Clone for PrecisionBound
impl Clone for PrecisionBound
Source§fn clone(&self) -> PrecisionBound
fn clone(&self) -> PrecisionBound
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more