Crate const_arithmetic
source ·Expand description
This crate is dedicated to implementing integer arithmetic that can be verified and used during compilation time
Macros
- Turns an integer (u32) into a typed integer object.
- This asserts the typed integer provided is the same as the number you provided
Structs
- A struct which generics represents an unique integer from 0 to 2 ** 32 - 1
- This denotes the number 0
- This denotes the number 1
- This denotes the number 2
- This denotes the number 3
- This denotes the number 4
- This denotes the number 5
- This denotes the number 6
- This denotes the number 7
- This denotes the number 8
- This denotes the number 9
- This denotes the number 10
- This denotes the number 11
- This denotes the number 12
- This denotes the number 13
- This denotes the number 14
- This denotes the number 15
Traits
- Asserts that a binary equals to _0
- Asserts that a binary equals to _1
- The AND logic gate
- The NXOR logic gate, or EQUAL operator
- The NOR logic gate
- The NOT logic gate
- The OR logic gate
- Indicates binary types.
- This denotes one single hexadecimal - half a byte
- This is an internal implementation of addition of 2 number
- This is an internal implementation of addition of three number
- This is an internal implementation of asserted equality on hexadecimal.
- This is an internal implementation of equality on hexadecimal. False evaluates to _0 and true evaluates to _1
- This is an internal implementation of multiplication of two hexadecimal
- A trait that denotes whether something is an integer Example
- Denotes integer addition. If this says C7 does not implement HexAssertEq, this means it overflowed.
- A trait that asserts two integers are equal Example
- Returns the Quotient of H/K for H: Div<K, Output: …> Note about implementation detail: This is an expanded version of long division - it takes O(1) steps but the constant is quite big unfortunately (to be precise its 32 multiplications plus a negligible amount of addition and subtraction and other stuff) If there were many divisions, the compile time increases quite a bit
- A trait that returns a binary depending on whether two integers are equal
- A trait that returns a binary depending on whether two integers are greater or equal
- A trait that returns a binary depending on whether a > b
- A trait that returns a binary depending on whether two integers are less or equal
- A trait that returns a binary depending on whether a < b
- A multiplication of 32 bit number and 32 bit number can be stored safely in a 64 bit number. We represent them as lower 32 bits and upper 32 bits
- Denotes integer subtraction. If this says C7 does not implement HexAssertEq, this means it underflowed.