Rats
Rationals are Onigiri256’s solution to floating-point numbers.
| "Rat" is shorthand for "rational." |
Overview
A rat is a replacement for a floating-point number. They’re supposed to replace IEEE 754 floating-point numbers by providing accurate representations, for example, for \(\frac{1}{3}\). Its constraints are defined by the ORF256 standard.
They come in four shapes: r32, r64, r128, and r256. These are all signed data types.
OPE1024 supports vectors for ORF256 data types.
Representing Irrational Numbers
Since a rational format inherently cannot represent irrational numbers, like \(\pi\), the best way to represent them with rats is a close approximation.
\(\pi\) can be represented as:
This is accurate for the first 77 decimal places of \(\pi\), \(3.1415926535897932384626433832795028841971693993751058209749445923078164062862\). The absolute error is roughly: \(8.6832546875453769 * 10^{-78}\). For perspective, \(\pi\) to 39 decimal places is already enough to calculate the circumference of the observable universe to about the width of a hydrogen atom.
ORF256 Standard
Representation
The representation of a rational is half the bits of the data type over half the bits of the data type. For example, \(\frac{\text{128-bits}}{\text{128-bits}}\) for r256.
Canonical Zero
The single canonical representation of zero in ORF256 is \(\frac{0}{1}\). Any other form where the denominator is not \(0\) is Undefined.
Comparison
Any two numbers that represent the same underlying number rationally will equal each other. For example, \(\frac{1}{3} = \frac{3}{9}\). The single exception being a denominator that’s zero.