#softfloat

softfloat-wrapper

a safe wrapper of Berkeley SoftFloat based on softfloat-sys

9 releases

0.3.3 Mar 16, 2021
0.3.2 Jan 15, 2021
0.2.0 Nov 8, 2020
0.1.3 Oct 5, 2020
0.1.1 Aug 20, 2020

#98 in Math

Download history 3/week @ 2021-07-03 4/week @ 2021-07-10 10/week @ 2021-07-17 15/week @ 2021-07-24 21/week @ 2021-07-31 18/week @ 2021-08-07 51/week @ 2021-08-14 75/week @ 2021-08-21 65/week @ 2021-08-28 16/week @ 2021-09-04 83/week @ 2021-09-11 49/week @ 2021-09-18 41/week @ 2021-09-25 9/week @ 2021-10-02 10/week @ 2021-10-09 2/week @ 2021-10-16

70 downloads per month

MIT/Apache

62KB
1.5K SLoC

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.3.3"

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).to_bits());
    let b = f32::from_bits(b.to_f32(RoundingMode::TiesToEven).to_bits());
    let d = f32::from_bits(d.to_f32(RoundingMode::TiesToEven).to_bits());

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

Feature

Some architectures are supported:

  • 8086
  • 8086-SSE (default)
  • ARM-VFPv2
  • ARM-VFPv2-DefaultNaN
  • RISCV

You can specify architecture through feature like below:

[dependencies.softfloat-wrapper]
version = "0.3.3"
default-features = false
features = ["riscv"]

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

~2MB
~26K SLoC