#soft-float #api-bindings

softfloat-wrapper-riscv

a safe wrapper of Berkeley SoftFloat based on softfloat-sys for RISC-V based on https://github.com/dalance/softfloat-wrapper

1 unstable release

0.1.0 Sep 22, 2020

#1498 in Math

MIT/Apache

1.5MB
21K SLoC

C 18K SLoC // 0.5% comments Rust 2.5K SLoC // 0.0% comments

softfloat-wrapper

softfloat-wrapper is a safe wrapper of Berkeley SoftFloat based on softfloat-sys.

Actions Status Crates.io Docs.rs

Usage

[dependencies]
softfloat-wrapper = "0.1.1"

Example

use softfloat_wrapper::{Float, F16, RoundingMode};

fn main() {
    let a = 0x1234;
    let b = 0x1479;

    let a = F16::from_bits(a);
    let b = F16::from_bits(b);
    let d = a.add(b, RoundingMode::TiesToEven);

    let a = f32::from_bits(a.to_f32(RoundingMode::TiesToEven).bits());
    let b = f32::from_bits(b.to_f32(RoundingMode::TiesToEven).bits());
    let d = f32::from_bits(d.to_f32(RoundingMode::TiesToEven).bits());

    println!("{} + {} = {}", a, b, d);
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~110–520KB
~11K SLoC