Radar · Rust · #003 · Week 41 · Oct 5 – 11, 2026
Add `f16b` type to core::num
Worth knowinglanguage
- What changed
- The RFC adds a
f16btype to Rust incore::num, with no support for scalar arithmetic. - Production impact
- The source does not say.
- Try it
- Read the RFC text and experiment with the type on a nightly compiler once it lands.
- Source
- github.com/rust-lang/rfcs/pull/3983
Understand it, then run it
Run it now
// The `f16b` type is not yet available in Rust 1.99.0 (edition 2024).
// We demonstrate the problem it solves by using a `u16` as a stand‑in
// for a 16‑bit floating‑point value and converting to `f32` for math.
fn main() {
// Imagine this `u16` holds the raw bits of an `f16b` value.
let raw: u16 = 0b0011_1100_0000_0000; // example bit pattern
// Convert the raw bits to `f32` using a manual conversion.
// In real code this would be `f32::from(f16b::from_bits(raw))`.
let f: f32 = f32::from_bits((raw as u32) << 16);
// Perform some arithmetic on the `f32`.
let result = f * 2.0 + 1.0;
// Convert back to the 16‑bit representation (truncating the mantissa).
let raw_result = (result.to_bits() >> 16) as u16;
println!("Original bits: {:#06x}", raw);
println!("As f32: {}", f);
println!("Result as f32: {}", result);
println!("Result bits (as f16b placeholder): {:#06x}", raw_result);
}
What it printed when we ran it on Rust 1.99.0 (edition 2024)
Original bits: 0x3c00 As f32: 0.0078125 Result as f32: 1.015625 Result bits (as f16b placeholder): 0x3f82
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-120b from the linked source · claims checked against the sources · human-reviewed