Crates.io | softfloat-wrapper |
lib.rs | softfloat-wrapper |
version | 0.3.4 |
source | src |
created_at | 2020-08-03 03:57:17.352742 |
updated_at | 2023-06-26 02:26:52.4266 |
description | a safe wrapper of Berkeley SoftFloat based on softfloat-sys |
homepage | |
repository | https://github.com/dalance/softfloat-wrapper |
max_upload_size | |
id | 272395 |
size | 89,249 |
softfloat-wrapper is a safe wrapper of Berkeley SoftFloat based on softfloat-sys.
[dependencies]
softfloat-wrapper = "0.3.4"
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);
}
Some architectures are supported:
You can specify architecture through feature like below:
[dependencies.softfloat-wrapper]
version = "0.3.4"
default-features = false
features = ["riscv"]
Licensed under either of
at your option.
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.