NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #284 most downloaded on crates.io
Half-precision floating point f16 and bf16 types for Rust implementing the IEEE 754-2008 standard binary16 and bfloat16 types.
Latest stable
2.7.1
Last release 1 years ago
14 Oct 2025
Release timing varies
gaps range from 8 days to 11 months
Nearly every release is documented
notes for 29 of 29 stable releases
4 versions withdrawn
withdrawn after publishing
11 years old
33 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
loongarch64 lsx hardware intrinsics for f16 conversions now enabled only under nightly cargo feature, fixing compile errors on stable Rust.
loongarch64 lsx hardware intrinsics for f16 conversions now enabled only under nightly cargo feature, fixing compile errors on stable Rust.zerocopy is now a required dependency. The optional zerocopy crate feature is deprecated. This change is to ensure better code safety and prevent pote…
zerocopy is now a required dependency. The optional zerocopy crate feature is deprecated. This change is to ensure better code safety and prevent potential unsound behavior.num-traits implementations: Signed for f16 and bf16. By @djsell.loongarch64 lsx hardware intrinsic support for f16 conversions. By @heiher.Weight trait from rand crate for f16 and bf16 with rand optional cargo feature. By @majian4work.min and max incorrectly propagate NaN values when self is NaN. Fixes #126, by @mgottscho.unnecessary_transmutes lint.doc_auto_cfg feature has been removed from docs.rs documentation due to removal of rust feature.Your coding agent can read these notes before it upgrades. Set up the MCP server →
Fixed some incorrect minimum supported versions of dependencies that weren't caught due to improper Cargo.lock :
Cargo.lock:
num-traits 0.2.14 -> 0.2.16zerocopy 0.8.0 -> 0.8.23arbitrary 1.3.2 -> 1.4.1f16 and bf16 now implement Immutable and KnownLayout for zerocopy crate. By [@usamoi].Cargo.lock:
num-traits 0.2.14 -> 0.2.16zerocopy 0.8.0 -> 0.8.23arbitrary 1.3.2 -> 1.4.1f16 and bf16 now implement Immutable and KnownLayout for zerocopy crate. By [@usamoi].Updated optional dependencies to latest major versions:
zercopy 0.6 -> 0.8rand 0.8 -> 0.9rand_distr 0.4 -> 0.5rkyv 0.7 -> 0.8criterion 0.4 -> 0.5arbitrary crate. Fixes #110. By @FL33TW00D.num-traits implementations: FromBytes and ToBytes for f16 and bf16. By @kpreid.f16 primitive in compiler.Missing macro import causing build failure on no_std + alloc feature set. Fixes #107 .
no_std + alloc feature set. Fixes #107.Optional rkyv support. Fixes #100 , by @comath .
rkyv support. Fixes #100, by @comath.num-traits implementations: AsPrimitive<f16> for bf16 and AsPrimitive<bf16> forf16, allowing lossy conversions between the two types. By @charles-r-earp.Cargo.lock added to vcs as is now recommended for library crates.Compile error on x86 (not x86_64) targets. Fixes #93 .
Breaking Change Minimum supported Rust version is now 1.70.
rand_distr::Distribution implementations behind rand_distr optional cargo feature. By @coreylowman.Display and Debug implementations. By @eiz.std only), including:
use-intrinsics cargo feature no longer used. Hardware support will now always be used whenever possible. A future version may output deprecation warnings if this feature is enabled.leading_zeros functions by inlining. By @encounter.Sum implementation of bf16 incorrectly performed product instead of sum. By @wx-csy.serde cargo feature enabled but std not enabled.Reduced unnecessary bounds checks for SIMD operations on slices. By @Shnatsel .
Add serialize_as_f32 and serialize_as_string functions when serde cargo feature is enabled. They allowing customizing the serialization by using #[ser
serialize_as_f32 and serialize_as_string functions when serde cargo feature is enabled. They allowing customizing the serialization by using #[serde(serialize_with="f16::serialize_as_f32")] attribute in serde derive macros. Closes #60.f32, f64, and string values in addition to its previous default deserialization. Closes #60.#[inline] on fallback functions, which improved conversion execution on non-nightly rust by up to 50%. By @Shnatsel.Add support for target_arch spirv. Some traits and functions are unavailble on this architecture. By @charles-r-earp.
spirv. Some traits and functions are unavailble on this architecture. By @charles-r-earp.total_cmp method to both float types. Closes #55, by @joseluis.Breaking Change Minimum supported Rust version is now 1.58.
std is now enabled as a default cargo feature. Disable default features to continue using no_std support.#[must_use] attributes to functions, as appropriate.slice::as_ptr not correctly using mutable reference. By @Nilstrieb.const conversion methods to both f16 and bf16. These methods never use hardware intrinsics, unlike the current conversion methods, which is why they are separated into new methods. The following const methods were added:
from_f32_constfrom_f64_constto_f32_constto_f64_constNeg trait support for borrowed values &f16 and &bf16. By @pthariensflame.AsPrimitive implementations from and to self, usize, and isize. By @kali.serialize cargo feature has been removed. Use serde cargo feature instead.consts module has been removed. Use associated constants on f16 instead.f16::as_bitsslice::from_bits_mutslice::to_bits_mutslice::from_bitsslice::to_bitsvec::from_bitsvec::to_bitsPotential soundness issues resolved.
Remove cargo resolver=2 from manifest to resolve errors in older versions of Rust that still worked with 1.8.0. Going forward, MSRV increases will be
*Not recommended due to introducing compilation error in Rust versions that worked with 1.8.0.*
Not recommended due to introducing compilation error in Rust versions that worked with 1.8.0.
std feature on optional dependencies.std feature is not enabled and num-traits is enabled under new resolver. Now properly uses libm num-traits feature.Now always implements Add, Div, Mul, Neg, Rem, and Sub traits. Previously, these were only implemented under the num-traits feature. Keep in mind they
Add, Div, Mul, Neg, Rem, and Sub traits. Previously, these were only implemented under the num-traits feature. Keep in mind they still convert to f32 and back in the implementation.f16 and bf16 are now const:
to_le_bytesto_be_bytesto_ne_bytesfrom_le_bytesfrom_be_bytesfrom_ne_bytesis_normalclassifysignumzerocopy traits AsBytes and FromBytes under zerocopy cargo feature. By @samcrow.core::iter::Product and core::iter::Sum traits, with the same caveat as above about converting to f32 and back under the hood.NEG_ONE to both f16 and bf16.f16 and bf16:
copysignmaxminclampDocs.rs now generates docs for bytemuck and num-traits optional features.
bytemuck and num-traits optional features.Added optional implementations of bytemuck traits Zeroable and Pod under bytemuck cargo feature. By @charles-r-earp.
bytemuck traits Zeroable and Pod under bytemuck cargo feature. By @charles-r-earp.num-traits traits ToPrimitive and FromPrimitive under num-traits cargo feature. By @charles-r-earp.Binary, Octal, LowerHex, and UpperHex string format traits to format raw f16/bf16 bytes to string.Debug trait implementation now formats f16/bf16 as float instead of raw bytes hex. Use newly implemented formatting traits to format in hex instead of Debug. Fixes #37.Added LOG2_10 and LOG10_2 constants to both f16 and bf16, which were added to f32 and f64 in the standard library in 1.43.0. By @tspiteri.
LOG2_10 and LOG10_2 constants to both f16 and bf16, which were added to f32 and
f64 in the standard library in 1.43.0. By @tspiteri.to_le/be/ne_bytes and from_le/be/ne_bytes to both f16 and bf16, which were added to
the standard library in 1.40.0. By @bzm3r.Added the alloc feature to support the alloc crate in no_std environments. By @zserik. The vec module is now available with either alloc or std featur
alloc feature to support the alloc crate in no_std environments. By @zserik. The vec module is now available with either alloc or std feature.Added #[repr(transparent)] to f16/bf16 to remove undefined behavior. By @jfrimmel.
#[repr(transparent)] to f16/bf16 to remove undefined behavior. By @jfrimmel.New associated constants on f16 type to replace deprecated consts module.
bf16 type implementing the alternative bfloat16 16-bit floating point format. By @tspiteri.f16::from_bits, f16::to_bits, f16::is_nan, f16::is_infinite, f16::is_finite, f16::is_sign_positive, and f16::is_sign_negative are now const fns.slice::HalfBitsSliceExt and slice::HalfBitsSliceExt extension traits have been added for performing efficient reinterpret casts and conversions of slices to and from [f16] and [bf16]. These traits will use hardware SIMD conversion instructions when available and the use-intrinsics cargo feature is enabled.vec::HalfBitsVecExt and vec::HalfFloatVecExt extension traits have been added for performing efficient reinterpret casts to and from Vec<f16> and Vec<bf16>. These traits are only available with the std cargo feature.prelude has been added, for easy importing of most common functionality. Currently the prelude imports f16, bf16, and the new slice and vec extension traits.f16 type to replace deprecated consts module.use-intrinsics feature) now matches hardware rounding by rounding to nearest, ties to even. Fixes #24, by @tspiteri.f32 to f64 conversions, retaining sign. Fixes #23, by @tspiteri.std and use-intrinsics features are enabled and the compile target host does not support required features.use-intrinsics feature is enabled, will now always compile and run without error correctly regardless of compile target options.consts module and all its constants have been deprecated; use the associated constants on f16 instead.slice::from_bits has been deprecated; use slice::HalfBitsSliceExt::reinterpret_cast instead.slice::from_bits_mut has been deprecated; use slice::HalfBitsSliceExt::reinterpret_cast_mut instead.slice::to_bits has been deprecated; use slice::HalfFloatSliceExt::reinterpret_cast instead.slice::to_bits_mut has been deprecated; use slice::HalfFloatSliceExt::reinterpret_cast_mut instead.vec::from_bits has been deprecated; use vec::HalfBitsVecExt::reinterpret_into instead.vec::to_bits has been deprecated; use vec::HalfFloatVecExt::reinterpret_into instead.Corrected values of constants EPSILON, MAX_10_EXP, MAX_EXP, MIN_10_EXP, and MIN_EXP in consts module, as well as setting consts::NAN to match value of
EPSILON, MAX_10_EXP, MAX_EXP, MIN_10_EXP, and MIN_EXP
in consts module, as well as setting consts::NAN to match value of f32::NAN convertd to
f16. By @tspiteri.slice::from_bits_mut and slice::to_bits_mut for conversion between mutable u16 and f16 slices. Fixes #16, by @johannesvollmer.
slice::from_bits_mut and slice::to_bits_mut for conversion between mutable u16 and f16
slices. Fixes #16, by @johannesvollmer.as_bits has been deprecated; use to_bits instead.
slice and optional vec (only included with std feature) modules for conversions between u16 and f16
buffers. Fixes #14, by @johannesvollmer.to_bits added to replace as_bits. Fixes #12, by @tspiteri.serde optional dependency no longer uses its default std feature.as_bits has been deprecated; use to_bits instead.serialize cargo feature is deprecated; use serde instead.Fixed compilation error in 1.1.1 on rustc < 1.27, now compiles again on rustc >= 1.10. Fixes #11.
*Not recommended due to introducing compilation error on rustc versions prior to 1.27.*
Not recommended due to introducing compilation error on rustc versions prior to 1.27.
use-intrinsics is not enabled. By @Moongoodboy-K.Made to_f32 and to_f64 public. Fixes #7, by @PSeitz.
to_f32 and to_f64 public. Fixes #7, by @PSeitz.Update behavior of is_sign_positive and is_sign_negative to match the IEEE754 conforming behavior of the standard library since Rust 1.20.0. Fixes #3,
is_sign_positive and is_sign_negative to match the IEEE754 conforming
behavior of the standard library since Rust 1.20.0. Fixes #3, by @tspiteri.is_nan and is_infinite from @tspiteri.f16 and f32 to f16, and case where f64 NaN could be
converted to f16 infinity instead of NaN. Fixes #5, by @tspiteri.Badges and categories in crate metadata.
serde dependency updated to 1.0 stable.Update to serde 0.9 and stable Rust 1.15 for serialize feature.
serde 0.9 and stable Rust 1.15 for serialize feature.Add serde support under new serialize feature.
serde support under new serialize feature.no_std for crate by default.### Added - Initial release of f16 type.
f16 type.One column per quarter.