mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 03:50:39 +00:00
⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# Obifp Package: Generic Fixed-Point Unsigned Integer Operations
|
||||
|
||||
This Go package (`obifp`) provides a generic, type-safe interface for fixed-point unsigned integer arithmetic over three size variants: `Uint64`, `Uint128`, and `Uint256`.
|
||||
|
||||
## Core Interface: `FPUint[T]`
|
||||
|
||||
The interface defines a unified API for unsigned integer types, supporting:
|
||||
|
||||
- **Initialization & Conversion**:
|
||||
- `Zero()`, `Set64(v)`: Create zero or set from a `uint64`.
|
||||
- `AsUint64()`: Downcast to standard `uint64`.
|
||||
|
||||
- **Logical Operations**:
|
||||
- Bitwise: `And`, `Or`, `Xor`, `Not`.
|
||||
- Shifts: `LeftShift(n)`, `RightShift(n)`.
|
||||
|
||||
- **Arithmetic**:
|
||||
- Addition (`Add`), subtraction (`Sub`), multiplication (`Mul`). Division is commented out—likely reserved for future implementation.
|
||||
|
||||
- **Comparison**:
|
||||
- Full ordering: `<`, `<=`, `>`, `>=`.
|
||||
|
||||
- **Utility Predicates**:
|
||||
- `IsZero()` for zero-checking.
|
||||
|
||||
## Helper Functions
|
||||
|
||||
- `ZeroUint[T]`: Returns the neutral element (zero) for type `T`.
|
||||
- `OneUint[T]`: Constructs value 1 via `Set64(1)`.
|
||||
- `From64[T]`: Converts a standard Go `uint64` into the generic type.
|
||||
|
||||
All operations are **method-chaining friendly** (return `T`, not pointers), enabling fluent syntax. The design promotes correctness and performance in cryptographic or financial contexts where large, fixed-size integers are required.
|
||||
Reference in New Issue
Block a user