#floating-point #atomic #atomicf32

no-std atomic_float

Floating point types which can be safely shared between threads

3 releases (stable)

1.1.0 Aug 31, 2024
1.0.0 May 4, 2024
0.1.0 Sep 14, 2020

#53 in Concurrency

Download history 188869/week @ 2025-10-09 201094/week @ 2025-10-16 227299/week @ 2025-10-23 215515/week @ 2025-10-30 210187/week @ 2025-11-06 243323/week @ 2025-11-13 209744/week @ 2025-11-20 141660/week @ 2025-11-27 321515/week @ 2025-12-04 327551/week @ 2025-12-11 206712/week @ 2025-12-18 71330/week @ 2025-12-25 204711/week @ 2026-01-01 364154/week @ 2026-01-08 363281/week @ 2026-01-15 439146/week @ 2026-01-22

1,386,223 downloads per month
Used in 526 crates (44 directly)

Apache-2.0 OR MIT OR Unlicense

67KB
386 lines

atomic_float

Build Status codecov Docs Latest Version

This crate provides AtomicF32 and AtomicF64 types that behave almost identically to the integer atomics in the stdlib.

Usage

use atomic_float::AtomicF32;
use core::sync::atomic::Ordering::Relaxed;

static A_STATIC: AtomicF32 = AtomicF32::new(800.0);

// Should support the full std::sync::atomic::AtomicFoo API
A_STATIC.fetch_add(30.0, Relaxed);
A_STATIC.fetch_sub(-55.0, Relaxed);
// But also supports things that can be implemented
// efficiently easily, like sign-bit operations.
A_STATIC.fetch_neg(Relaxed);

assert_eq!(A_STATIC.load(Relaxed), -885.0);

License

Licensed under either of

at your option.

Dependencies

~160KB