amplify_num/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2//
3// Written in 2020-2026 by Dr. Maxim Orlovsky <orlovsky@ubideco.org>
4//
5// Copyright 2024-2026 Laboratories for Ubiquitous and Deterministic Computing,
6// Institute for Distributed and Cognitive Computing (InDCS), Switzerland.
7// All rights reserved.
8//
9// Copyright (C) 2020-2026 Dr Maxim Orlovsky.
10// All rights reserved.
11//
12// Licensed under the Apache License, Version 2.0 (the "License"); you may not
13// use this file except in compliance with the License. You may obtain a copy of
14// the License at <http://www.apache.org/licenses/LICENSE-2.0>
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19// License for the specific language governing permissions and limitations under
20// the License.
21
22//! Custom-sized numeric types.
23//!
24//! Implementation of various integer types with custom bit dimension. This
25//! includes:
26//! * large signed and unsigned integers, named *large int types* (256, 512,
27//! 1024-bit)
28//! * custom sub-8-bit unsigned integers, named *small int types* (from 1 to
29//! 7-bit)
30//! * 10-, 12-, 14-, 20-, 24-, 40-, 48- and 56-bit unsigned integer.
31//!
32//! The functions here are designed to be fast.
33
34#![cfg_attr(not(feature = "std"), no_std)]
35#[cfg(feature = "alloc")]
36extern crate alloc;
37extern crate core;
38
39#[cfg(feature = "serde")]
40#[macro_use]
41extern crate serde_crate as serde;
42
43mod bigint;
44pub mod error;
45#[cfg(feature = "hex")]
46pub mod hex;
47pub mod posit;
48mod smallint;
49
50pub use bigint::{i256, i512, i1024, u256, u512, u1024};
51pub use smallint::{u1, u2, u3, u4, u5, u6, u7, u10, u12, u14, u20, u24, u40, u48, u56};
52
53// TODO: Create arbitrary precision types
54// TODO: Move from using `u64` to `u128` for big int types