Struct arpfloat::Semantics

source ·
pub struct Semantics {
    pub exponent: usize,
    pub precision: usize,
}
Expand description

Controls the semantics of a floating point number using two fields: ‘precision’, that determines the number of bits, and ‘exponent’ that controls the dynamic range of the number.

Fields§

§exponent: usize

The number of bits that define the range of the exponent.

§precision: usize

The number of bits in the significand (mantissa + 1).

Implementations§

Examples found in repository?
examples/print_bench.rs (line 7)
6
7
8
9
10
11
fn main() {
    let sem = Semantics::new(32, 5000);
    let val = Float::e(sem);
    println!("F64: {}", val.as_f64());
    println!("FP*: {}", val);
}

Returns the precision in bits.

Returns the length of the mantissa in bits (precision - 1).

Returns the length of the exponent in bits, which defines the valid range.

Create a new float semantics with increased precision with ‘add’ additional digits.

Create a new float semantics with increased precision with ‘add’ additional digits, plus ceil(log2) of the number.

Create a new float semantics with increased exponent with ‘more’ additional digits.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.