Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies, fix u1::to_u8, version bump #18

Merged
merged 10 commits into from
Feb 15, 2024
42 changes: 16 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions apfloat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = [
"Yudai Kiyofuji <[email protected]>"
]
name = "amplify_apfloat"
version = "0.2.0"
version = "0.3.0"
description = "rustc_apfloat with u256 backend to utilize Octuple precision floating-point format"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-amplify/rust-amplify"
Expand All @@ -21,8 +21,8 @@ alloc = ["amplify_num/alloc"]
std = ["amplify_num/std"]

[dependencies]
amplify_num = { version = "0.5.0", path = "../num", default-features = false }
bitflags = "1.0"
amplify_num = { version = "0.6.0", path = "../num", default-features = false }
bitflags = "2.4.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
Expand All @@ -31,8 +31,3 @@ getrandom = { version = "0.2", features = ["js"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[target.'cfg(target_arch = "wasm32")'.features]
default = ["std"]
alloc = ["amplify_num/alloc"]
std = ["amplify_num/std"]
3 changes: 2 additions & 1 deletion apfloat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ mod status {
///
/// UNDERFLOW or OVERFLOW are always returned or-ed with INEXACT.
#[must_use]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Status: u8 {
const OK = 0x00;
const INVALID_OP = 0x01;
Expand All @@ -98,7 +99,7 @@ mod status {
pub use status::Status;

#[must_use]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct StatusAnd<T> {
pub status: Status,
pub value: T,
Expand Down
13 changes: 2 additions & 11 deletions num/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amplify_num"
version = "0.5.1"
version = "0.6.0"
description = "Amplifying numeric types: big-sized and bit-sized integers"
authors = [
"Dr. Maxim Orlovsky <[email protected]>",
Expand All @@ -21,8 +21,7 @@ rust-version = "1.60.0"
serde_crate = { package = "serde", version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
bincode = "1.3.3"
rand = "0.8.4"
rand = "0.8.5"
serde_crate = { package = "serde", version = "1.0", features = ["derive"] }
serde_json = "1"

Expand All @@ -41,11 +40,3 @@ getrandom = { version = "0.2", features = ["js"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[target.'cfg(target_arch = "wasm32")'.features]
default = ["hex"]
all = ["std", "hex", "serde"]
std = []
serde = ["std", "serde_crate", "hex"]
hex = []
alloc = []
14 changes: 5 additions & 9 deletions num/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//
// Written in 2014 by
// Andrew Poelstra <[email protected]>
// Refactored & fixed in 2021 by
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
// Refactored & fixed in 2021-2024 by
// Dr. Maxim Orlovsky <orlovsky@ubideco.org>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
Expand Down Expand Up @@ -1526,7 +1526,7 @@ mod tests {
#[test]
fn fmt_hex() {
let one = u256::ONE;
let mut u_256 =
let u_256 =
u256([0x0000000000000000, 0xAAAAAAAABBBBBBBB, 0x0000000111122222, 0x0000000000000000]);

// UpperHex
Expand Down Expand Up @@ -1554,7 +1554,7 @@ mod tests {
#[test]
fn fmt_octal() {
let one = u256::ONE;
let mut u_256 = u256([
let u_256 = u256([
0o0000000000000000000000,
0o0011222222222222222222,
0o0000000001111111111111,
Expand All @@ -1581,7 +1581,7 @@ mod tests {
#[test]
fn fmt_binary() {
let one = u256::ONE;
let mut u_256 = u256([
let u_256 = u256([
0b0000000000000000000000000000000000000000000000000000000000000000,
0b0001111000011110001111000011110001111000011110001111000011110000,
0b0000000000000000000000000000001111111111111111111111111111111111,
Expand Down Expand Up @@ -1867,10 +1867,6 @@ mod tests {
let json = format!("\"{}\"", hex);
assert_eq!(::serde_json::to_string(&uint).unwrap(), json);
assert_eq!(::serde_json::from_str::<u256>(&json).unwrap(), uint);

let bin_encoded = ::bincode::serialize(&uint).unwrap();
let bin_decoded: u256 = ::bincode::deserialize(&bin_encoded).unwrap();
assert_eq!(bin_decoded, uint);
};

check(u256::from(0u64), "0000000000000000000000000000000000000000000000000000000000000000");
Expand Down
10 changes: 5 additions & 5 deletions num/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//
// Written in 2014 by
// Andrew Poelstra <[email protected]>
// Updated in 2020-2021 by
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
// Updated in 2020-2024 by
// Dr. Maxim Orlovsky <orlovsky@ubideco.org>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
Expand All @@ -17,11 +17,11 @@

#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
/// Error indicating that a value does not fit integer dimension
pub struct OverflowError {
pub struct OverflowError<T = usize> {
/// Integer bit size
pub max: usize,
pub max: T,
/// Value that overflows
pub value: usize,
pub value: T,
}

impl core::fmt::Display for OverflowError {
Expand Down
17 changes: 8 additions & 9 deletions num/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Rust language amplification library providing multiple generic trait
// implementations, type wrappers, derive macros and other language enhancements
//
// Written in 2014 by
// Andrew Poelstra <[email protected]>
// Updated in 2020-2021 by
// Dr. Maxim Orlovsky <[email protected]>
// Written in 2020-2024 by
// Dr. Maxim Orlovsky <[email protected]>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
Expand All @@ -17,12 +15,13 @@

//! Custom-sized numeric types
//!
//! Implementation of a various integer types with custom bit dimension. These
//! Implementation of a various integer types with custom bit dimension. This
//! includes:
//! * large signed and unsigned integers, named *gib int types* (256, 512,
//! * large signed and unsigned integers, named *large int types* (256, 512,
//! 1024-bit)
//! * custom sub-8 bit unsigned integers, named *small int types (5-, 6-, 7-bit)
//! * 24-bit signed integer.
//! * custom sub-8 bit unsigned integers, named *small int types* (from 1 to
//! 7-bit)
//! * 24-, 40-, 48- and 56-bit unsigned integer.
//!
//! The functions here are designed to be fast.

Expand All @@ -43,7 +42,7 @@ pub mod posit;
mod smallint;

pub use bigint::{i1024, i256, i512, u1024, u256, u512};
pub use smallint::{u1, u2, u24, u3, u4, u5, u6, u7};
pub use smallint::{u1, u2, u24, u3, u4, u40, u48, u5, u56, u6, u7};

// TODO: Create arbitrary precision types
// TODO: Move from using `u64` to `u128` for big int types
Loading
Loading