-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlib.rs
67 lines (62 loc) · 1.36 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Low-level manipulations of IEEE754 floating-point numbers.
//!
//! # Installation
//!
//! Add this to your Cargo.toml:
//!
//! ```toml
//! [dependencies]
//! ieee754 = "0.2"
//! ```
//!
//! To enable `rayon` parallel iteration, activate the optional
//! `rayon` feature:
//!
//! ```toml
//! [dependencies]
//! ieee754 = { version = "0.2", features = ["rayon"] }
//! ```
//!
//! # Examples
//!
//! ```rust
//! use ieee754::Ieee754;
//!
//! // there are 840 single-precision floats between 1.0 and 1.0001
//! // (inclusive).
//! assert_eq!(1_f32.upto(1.0001).count(), 840);
//! ```
//!
//! If `rayon` is enabled, this can be performed in parallel:
//!
//! ```rust
//! extern crate ieee754;
//! # #[cfg(feature = "rayon")]
//! extern crate rayon;
//!
//! # #[cfg(feature = "rayon")]
//! # fn main() {
//! use ieee754::Ieee754;
//! use rayon::prelude::*;
//!
//! // there are 840 single-precision floats between 1.0 and 1.0001
//! // (inclusive).
//! assert_eq!(1_f32.upto(1.0001).into_par_iter().count(), 840);
//! # }
//! # #[cfg(not(feature = "rayon"))] fn main() {}
//! ```
#![no_std]
#![cfg_attr(nightly, feature(try_trait))]
#[cfg(test)] #[macro_use] extern crate std;
mod iter;
mod impls;
mod traits;
pub use traits::{Bits, Ieee754};
pub use iter::Iter;
#[cfg(feature = "rayon")]
pub use iter::rayon::ParIter;
#[inline]
#[doc(hidden)]
pub fn abs<F: Ieee754>(x: F) -> F {
x.abs()
}