Skip to content

Commit

Permalink
special float numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelica-Schell committed Dec 4, 2024
1 parent bbdb7a0 commit e70b0d1
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions tools/data-conversion/src/float_special_values
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,6 @@ pub struct IntermediateRepresentation {
}

impl IntermediateRepresentation {
// Function to create a NaN
pub fn create_nan(bit_width: usize) -> Self {
let exponent = (1 << (bit_width - 1)) - 1; // Max exponent for NaN
let mantissa = BigUint::from(1u64); // Set least significant bit of mantissa
IntermediateRepresentation {
sign: false, // NaN is typically unsigned
mantissa,
exponent: exponent as i64,
}
}

// Function to create infinity (positive or negative)
pub fn create_infinity(sign: bool, bit_width: usize) -> Self {
let exponent = (1 << (bit_width - 1)) - 1; // Max exponent for infinity
let mantissa = BigUint::zero(); // Mantissa should be zero for infinity
IntermediateRepresentation {
sign,
mantissa,
exponent: exponent as i64,
}
}

// Function to create a denormalized number
pub fn create_denormalized(mantissa: BigUint) -> Self {
IntermediateRepresentation {
sign: false, // Denormalized numbers are typically positive
mantissa,
exponent: 0, // Exponent is zero for denormalized numbers
}
}

// Function to create zero (positive or negative)
pub fn create_zero(sign: bool) -> Self {
IntermediateRepresentation {
sign,
mantissa: BigUint::zero(),
exponent: 0,
}
}

// Function to check if the value is NaN
pub fn is_nan(&self, bit_width: usize) -> bool {
let max_exponent_value = (1 << (bit_width - 1)) - 1; // Max exponent for NaN
Expand Down

0 comments on commit e70b0d1

Please sign in to comment.