https://github.com/dalance/softfloat-wrapper
a safe wrapper of Berkeley SoftFloat based on softfloat-sys
https://github.com/dalance/softfloat-wrapper
Last synced: 9 months ago
JSON representation
a safe wrapper of Berkeley SoftFloat based on softfloat-sys
- Host: GitHub
- URL: https://github.com/dalance/softfloat-wrapper
- Owner: dalance
- License: apache-2.0
- Created: 2020-08-03T03:48:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-26T02:27:00.000Z (almost 3 years ago)
- Last Synced: 2024-05-02T01:00:54.786Z (about 2 years ago)
- Language: Rust
- Size: 25.4 KB
- Stars: 9
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# softfloat-wrapper
softfloat-wrapper is a safe wrapper of [Berkeley SoftFloat](https://github.com/ucb-bar/berkeley-softfloat-3) based on [softfloat-sys](https://crates.io/crates/softfloat-sys).
[](https://github.com/dalance/softfloat-wrapper/actions)
[](https://crates.io/crates/softfloat-wrapper)
[](https://docs.rs/softfloat-wrapper)
## Usage
```Cargo.toml
[dependencies]
softfloat-wrapper = "0.3.4"
```
## Example
```rust
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:
```Cargo.toml
[dependencies.softfloat-wrapper]
version = "0.3.4"
default-features = false
features = ["riscv"]
```
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
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.