#atomic #float #floating-point #atomicf32

no-std atomic_float

Floating point types which can be safely shared between threads

2 releases (1 stable)

1.0.0 May 4, 2024
0.1.0 Sep 14, 2020

#38 in Concurrency

Download history 18350/week @ 2024-01-24 16064/week @ 2024-01-31 17472/week @ 2024-02-07 15453/week @ 2024-02-14 15704/week @ 2024-02-21 14797/week @ 2024-02-28 12452/week @ 2024-03-06 14936/week @ 2024-03-13 14671/week @ 2024-03-20 14644/week @ 2024-03-27 12919/week @ 2024-04-03 12197/week @ 2024-04-10 14772/week @ 2024-04-17 15447/week @ 2024-04-24 12273/week @ 2024-05-01 13553/week @ 2024-05-08

58,827 downloads per month
Used in 300 crates (15 directly)

Apache-2.0 OR MIT OR Unlicense

68KB
394 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

~175KB