| Crates.io | certums |
| lib.rs | certums |
| version | 0.2.1 |
| created_at | 2025-10-13 23:23:14.94672+00 |
| updated_at | 2025-10-23 18:12:15.901063+00 |
| description | (INDEV) Yet another fixed-point number system |
| homepage | |
| repository | https://github.com/MisterSirCode/certums |
| max_upload_size | |
| id | 1881310 |
| size | 72,298 |
This is a simple numeric extension in rust that implements low-level fixed-sized fixed-point numbers as well as extensions and utilities for them in many different forms.
Certums and their variants are fixed-point values with whole number and fractional components. Acutes are fractional numbers with no whole number components.
The goal is to have a flexible and high-precision number system for tasks that rely largely on fractional components over supporting whole-number values.
These values are easily (Though lossily) convertable between eachother through simple bit-shifts, making them a convenient and easy-to-use format.
Certums (and variants) and Acutes are quite simple and defined by simple structures, n representing bit count:
Unsigned Certum:
log_2(n) - 1 whole bits, n - log_2(n) + 1 fractional bits.Signed Certums:
1 sign bit, log_2(n) - 2 whole bits, n - log_2(n) + 1 fractional bits.Unsigned Quarta:
n / 4 whole bits, n - n / 4 fractional bits.Signed Quarta:
1 sign bit, n / 4 - 1 whole bits, n - n / 4 fractional bits.Unsigned Dimid:
n / 2 whole bits, n - n / 2 fractional bits.Signed Dimid:
1 sign bit, n / 2 - 1 whole bits, n - n / 2 fractional bits.Unsigned Acutes:
n fractional bits.Signed Acutes:
1 sign bit, n - 1 fractional bits.For data ranges, type any value into wolframalpha to see its full decimal format.
Certum Data Ranges:
| Bit Depth | Min Signed | Max Signed | Min Unsigned | Max Unsigned | Integer:Fraction Signed | Integer:Fraction Unsigned |
|---|---|---|---|---|---|---|
| 8 Bits | -2 + 2-6 | 2 - 2-6 | 0 | 4 - 2-6 | 1:6 | 2:6 |
| 16 Bits | -4 + 2-13 | 4 - 2-13 | 0 | 8 - 2-13 | 2:13 | 3:13 |
| 32 Bits | -8 + 2-28 | 8 - 2-28 | 0 | 16 - 2-28 | 3:28 | 4:28 |
| 64 Bits | -16 + 2-59 | 16 - 2-59 | 0 | 32 - 2-59 | 4:59 | 5:59 |
| 128 Bits | -32 + 2-122 | 32 - 2-122 | 0 | 64 - 2-122 | 5:122 | 6:122 |
Quarta Data Ranges:
| Bit Depth | Min Signed | Max Signed | Min Unsigned | Max Unsigned | Integer:Fraction Signed | Integer:Fraction Unsigned |
|---|---|---|---|---|---|---|
| 8 Bits | -2 + 2-6 | 2 - 2-6 | 0 | 4 - 2-6 | 1:6 | 2:6 |
| 16 Bits | -8 + 2-12 | 8 - 2-12 | 0 | 16 - 2-12 | 3:12 | 4:12 |
| 32 Bits | -128 + 2-24 | 128 - 2-24 | 0 | 256 - 2-24 | 7:24 | 8:24 |
| 64 Bits | -215 + 2-48 | 215 - 2-48 | 0 | 216 - 2-48 | 15:48 | 16:48 |
| 128 Bits | -231 + 2-96 | 231 - 2-96 | 0 | 232 - 2-96 | 31:96 | 32:96 |
Dimid Data Ranges:
| Bit Depth | Min Signed | Max Signed | Min Unsigned | Max Unsigned | Integer:Fraction Signed | Integer:Fraction Unsigned |
|---|---|---|---|---|---|---|
| 8 Bits | -8 + 2-4 | 8 - 2-4 | 0 | 16 - 2-4 | 3:4 | 4:4 |
| 16 Bits | -128 + 2-8 | 128 - 2-8 | 0 | 256 - 2-8 | 7:8 | 8:8 |
| 32 Bits | -215 + 2-16 | 215 - 2-16 | 0 | 216 - 2-16 | 15:16 | 16:16 |
| 64 Bits | -231 + 2-32 | 231 - 2-32 | 0 | 232 - 2-32 | 31:32 | 32:32 |
| 128 Bits | -263 + 2-64 | 263 - 2-64 | 0 | 264 - 2-64 | 63:64 | 64:64 |
Acute Data Ranges:
| Bit Depth | Min Signed | Max Signed | Min Unsigned | Max Unsigned |
|---|---|---|---|---|
| 8 Bits | -1 + 2-7 | 1 - 2-7 | 0 | 1 - 2-8 |
| 16 Bits | -1 + 2-15 | 1 - 2-15 | 0 | 1 - 2-16 |
| 32 Bits | -1 + 2-31 | 1 - 2-31 | 0 | 1 - 2-32 |
| 64 Bits | -1 + 2-63 | 1 - 2-63 | 0 | 1 - 2-64 |
| 128 Bits | -1 + 2-127 | 1 - 2-127 | 0 | 1 - 2-128 |
Translated:
Certum - Fixed
Quarta - Quarter
Dimidium - Half
Acute - Sharp