-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requires Rust >= 1.26.0.
- Loading branch information
Rouven Spreckels
committed
May 10, 2018
1 parent
6a5bab2
commit 72794d8
Showing
7 changed files
with
26 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "signifix" | ||
version = "0.8.0" | ||
version = "0.9.0" | ||
authors = [ | ||
"Rouven Spreckels <[email protected]>", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2016, 2017 Rouven Spreckels <[email protected]> | ||
// Copyright (c) 2016, 2017, 2018 Rouven Spreckels <[email protected]> | ||
// | ||
// Usage of the works is permitted provided that | ||
// this instrument is retained with the works, so that | ||
|
@@ -102,7 +102,6 @@ pub const SYMBOLS: [Option<&str>; 9] = [ | |
Some("Pi"), Some("Ei"), Some("Zi"), Some("Yi"), | ||
]; | ||
|
||
#[cfg(feature = "nightly")] | ||
/// Binary prefix factors from `1 024 ^ 1` to `1 024 ^ 8` indexed from `1` to | ||
/// `8`, or `1 024 ^ 0` indexed at `0`. | ||
pub const FACTORS: [f64; 9] = [ | ||
|
@@ -113,21 +112,6 @@ pub const FACTORS: [f64; 9] = [ | |
(1u128 << 70) as f64, (1u128 << 80) as f64, | ||
]; | ||
|
||
#[cfg(not(feature = "nightly"))] | ||
/// Binary prefix factors from `1 024 ^ 1` to `1 024 ^ 8` indexed from `1` to | ||
/// `8`, or `1 024 ^ 0` indexed at `0`. | ||
pub const FACTORS: [f64; 9] = [ | ||
1f64, | ||
1024f64, | ||
1048576f64, | ||
1073741824f64, | ||
1099511627776f64, | ||
1125899906842624f64, | ||
1152921504606847000f64, | ||
1180591620717411300000f64, | ||
1208925819614629200000000f64, | ||
]; | ||
|
||
impl Signifix { | ||
/// Signed significand normalized from `±1.000` over `±999.9` to `±1 023`. | ||
pub fn significand(&self) -> f64 { | ||
|
@@ -215,16 +199,9 @@ impl Display for Signifix { | |
} | ||
} | ||
|
||
#[cfg(feature = "nightly")] | ||
try_from! { i8, i16, i32, i64, i128, isize } | ||
#[cfg(feature = "nightly")] | ||
try_from! { u8, u16, u32, u64, u128, usize } | ||
|
||
#[cfg(not(feature = "nightly"))] | ||
try_from! { i8, i16, i32, i64, isize } | ||
#[cfg(not(feature = "nightly"))] | ||
try_from! { u8, u16, u32, u64, usize } | ||
|
||
try_from! { f32 } | ||
|
||
impl TryFrom<f64> for Signifix { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2016, 2017 Rouven Spreckels <[email protected]> | ||
// Copyright (c) 2016, 2017, 2018 Rouven Spreckels <[email protected]> | ||
// | ||
// Usage of the works is permitted provided that | ||
// this instrument is retained with the works, so that | ||
|
@@ -82,19 +82,19 @@ | |
//! | ||
//! ```toml | ||
//! [dependencies] | ||
//! signifix = "0.8" | ||
//! signifix = "0.9" | ||
//! | ||
//! # Optionally enable `try_from` and `i128_type` support on nightly Rust. | ||
//! # Optionally enable `try_from` support on nightly Rust. | ||
//! #[dependencies.signifix] | ||
//! #features = ["nightly"] | ||
//! ``` | ||
//! | ||
//! and this to your crate root: | ||
//! | ||
//! ``` | ||
//! // Optionally enable `try_from` and `i128_type` support on nightly Rust. | ||
//! // Optionally enable `try_from` support on nightly Rust. | ||
//! // Required if the `nightly` feature is enabled in your `Cargo.toml`. | ||
//! //#![feature(try_from, i128_type)] | ||
//! //#![feature(try_from)] | ||
//! | ||
//! extern crate signifix; | ||
//! ``` | ||
|
@@ -107,7 +107,7 @@ | |
//! jumps to the left or right while making maximum use of their occupied space: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::{metric, binary, Result}; | ||
|
@@ -163,7 +163,7 @@ | |
//! This is useful to smoothly refresh a transfer rate within a terminal: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use std::f64; | ||
|
@@ -214,7 +214,7 @@ | |
//! direction with positive numbers being padded to align with negative ones: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::metric::{Signifix, Result, DEF_MAX_LEN}; | ||
|
@@ -239,7 +239,7 @@ | |
//! positive numbers: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::metric::{Signifix, Error, Result}; | ||
|
@@ -261,7 +261,7 @@ | |
//! of powers of two, such as memory boundaries due to binary addressing: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::binary::{Signifix, Error, Result}; | ||
|
@@ -302,7 +302,7 @@ | |
//! `Signifix::fmt()` method: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::binary::{Signifix, Result}; | ||
|
@@ -347,7 +347,7 @@ | |
//! type via its methods: | ||
//! | ||
//! ``` | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
//! # #![cfg_attr(feature = "nightly", feature(try_from))] | ||
//! use signifix::TryFrom; // Until stabilized. | ||
//! | ||
//! use signifix::metric::{Signifix, Result}; | ||
|
@@ -390,7 +390,7 @@ | |
|
||
#![deny(missing_docs)] | ||
|
||
#![cfg_attr(feature = "nightly", feature(try_from, i128_type))] | ||
#![cfg_attr(feature = "nightly", feature(try_from))] | ||
|
||
use std::result; | ||
use std::error; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2016, 2017 Rouven Spreckels <[email protected]> | ||
// Copyright (c) 2016, 2017, 2018 Rouven Spreckels <[email protected]> | ||
// | ||
// Usage of the works is permitted provided that | ||
// this instrument is retained with the works, so that | ||
|
@@ -210,16 +210,9 @@ impl Display for Signifix { | |
} | ||
} | ||
|
||
#[cfg(feature = "nightly")] | ||
try_from! { i8, i16, i32, i64, i128, isize } | ||
#[cfg(feature = "nightly")] | ||
try_from! { u8, u16, u32, u64, u128, usize } | ||
|
||
#[cfg(not(feature = "nightly"))] | ||
try_from! { i8, i16, i32, i64, isize } | ||
#[cfg(not(feature = "nightly"))] | ||
try_from! { u8, u16, u32, u64, usize } | ||
|
||
try_from! { f32 } | ||
|
||
impl TryFrom<f64> for Signifix { | ||
|