| Crates.io | strict-num-extended |
| lib.rs | strict-num-extended |
| version | 0.5.0 |
| created_at | 2026-01-03 20:53:58.716341+00 |
| updated_at | 2026-01-20 20:04:20.366398+00 |
| description | Type-safe finite floating-point types for Rust - eliminate NaN and infinity at compile time |
| homepage | |
| repository | https://github.com/MiyakoMeow/strict-num-extended |
| max_upload_size | |
| id | 2020771 |
| size | 240,998 |
Type-safe finite floating-point numbers for Rust.
A Rust library providing zero-cost finite floating-point types through the type system, guaranteeing safety by eliminating NaN and infinity values at compile time or runtime.
| Type | Valid Range | Example |
|---|---|---|
FinF32 / FinF64 |
All real numbers | -∞ < x < ∞ |
NonNegativeF32 / NonNegativeF64 |
x ≥ 0 |
0.0, 1.5, 100.0 |
NonPositiveF32 / NonPositiveF64 |
x ≤ 0 |
0.0, -1.5, -100.0 |
NonZeroF32 / NonZeroF64 |
x ≠ 0 |
1.0, -1.0, 0.001 |
PositiveF32 / PositiveF64 |
x > 0 |
0.001, 1.0, 100.0 |
NegativeF32 / NegativeF64 |
x < 0 |
-0.001, -1.0, -100.0 |
NormalizedF32 / NormalizedF64 |
0.0 ≤ x ≤ 1.0 |
0.0, 0.5, 1.0 |
NegativeNormalizedF32 / NegativeNormalizedF64 |
-1.0 ≤ x ≤ 0.0 |
-0.5, -0.75, -1.0 |
SymmetricF32 / SymmetricF64 |
-1.0 ≤ x ≤ 1.0 |
-1.0, 0.0, 0.5, 1.0 |
All fallible operations return Result<T, FloatError> with detailed error information:
Error Types:
NaN - Value is Not a NumberPosInf - Value is positive infinityNegInf - Value is negative infinityOutOfRange - Value is outside the valid range for the target typeDivisionByZero - Division by zero occurredNoneOperand - Right-hand side operand is None in Option arithmeticThe FloatError enum provides comprehensive error information for proper error handling and debugging, allowing precise error matching and recovery strategies.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.