#no_std #f16

no-std half

Half-precision floating point f16 type for Rust implementing the IEEE 754-2008 binary16 type

9 releases (stable)

1.3.0 Oct 3, 2018
1.1.2 Jul 13, 2018
1.1.0 Mar 17, 2018
1.0.1 Aug 30, 2017
0.1.0 Mar 18, 2016

#10 in No standard library

Download history 5757/week @ 2019-04-29 4310/week @ 2019-05-06 6343/week @ 2019-05-13 6340/week @ 2019-05-20 5872/week @ 2019-05-27 5980/week @ 2019-06-03 6367/week @ 2019-06-10 5389/week @ 2019-06-17 6766/week @ 2019-06-24 6415/week @ 2019-07-01 5567/week @ 2019-07-08 6324/week @ 2019-07-15 6303/week @ 2019-07-22 6021/week @ 2019-07-29 6770/week @ 2019-08-05

22,027 downloads per month
Used in 113 crates (14 directly)

MIT/Apache

49KB
799 lines

half: f16 type for Rust

Crates.io docs.rs Build Status Build status

This crate implements a half-precision floating point f16 type for Rust implementing the IEEE 754-2008 binary16 type.

How-to Use

The f16 type provides all the same operations as a normal Rust float type, but since it is primarily leveraged for minimal floating point storage and no major hardware implements them, all math operations are done as an f32 type. f16 by default provides no_std support so can easily be used in embedded code where a smaller float is most useful.

Requries Rust 1.10 or greater.

See the crate documentation for more details.

Optional Features

  • serde - Implement Serialize and Deserialize traits for f16. This adds a dependency on the serde crate. Requires Rust >= 1.15.

  • use-intrinsics - Use hardware intrinsics for f16 conversions if available on the compiler host target. By default, without this feature, conversions are done only in software, which will be the fallback if the host target does not have hardware support. Available only on Rust nightly channel.

  • std - Use Rust std library. This enables the vec module, which contains zero-copy conversions for the Vec type. This allows fast conversion between raw Vec<u16> bits and Vec<f16> arrays, and vice versa.

More Documentation

License

This library is distributed under the terms of either of:

at your option.

Contributing

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

~223KB