Here is a carefully structured Markdown documentation for the JeffreySarnoff/AIFloats.jl repository, based on the contents of src/AIFloats.jl and inferred design:
AIFloats.jl
The internal constructive model for MicroFloats. A Julia package for modeling and working with abstract and concrete floating point types, supporting both signed/unsigned and finite/extended (Inf-supporting) variants.
Table of Contents
- Overview
- Installation
- Module Exports
- Core Concepts
- Type Hierarchy
- Key Functions
- Usage Examples
- Dependencies
- Development
- License
Overview
AIFloats.jl provides a flexible and extensible framework for defining and working with floating-point types. This includes support for various encodings, bit widths, signedness, and finite or extended (Inf-supporting) domains. It is intended for research, experimentation, or custom numerical types.
Installation
import Pkg
Pkg.add(url="https://github.com/JeffreySarnoff/AIFloats.jl.git")
Module Exports
The main exports from the AIFloats
module are:
Abstract Types
AbstractAIFloat
AbstractUnsigned
/AbstractUnsignedFinite
/AbstractUnsignedExtended
AbstractSigned
/AbstractSignedFinite
/AbstractSignedExtended
Concrete Types & Constructors
floats
,codes
AIFloat
— generalized constructorUnsignedFinite
,UnsignedExtended
SignedFinite
,SignedExtended
Typed Predicates
is_aifloat
,is_unsigned
,is_signed
,is_finite
,is_extended
Functions Over Types
encoding_sequence
,value_sequence
foundation_magnitudes
Bit/Value Counts
nBits
,nSigBits
,nFracBits
,nSignBits
,nExpBits
nNaNs
,nZeros
,nInfs
,nPosInfs
,nNegInfs
nPrenormalMagnitudes
,nSubnormalMagnitudes
,nNormalMagnitudes
,nMagnitudes
nValues
,nNumericValues
,nNonzeroNumericValues
nMagnitudes
,nNonzeroMagnitudes
nExpValues
,nNonzeroExpValues
nFiniteValues
,nNonzeroFiniteValues
Exponent Utilities
expBias
,expUnbiasedValues
,expMinValue
,expMaxValue
,expValues
Julia Support Functions
index1
,value_to_index
,index_to_value
,floatleast
ulp_distance
Core Concepts
- AbstractAIFloat: Root for all AI float types.
- Signedness: Support for both signed and unsigned floats.
- Finiteness: Both finite (no infinities) and extended (with ±Inf) types.
- Bit Layout: Customizable bit widths, exponent, and significand size.
Type Hierarchy
AbstractAIFloat
├─ AbstractUnsigned
│ ├─ AbstractUnsignedFinite
│ └─ AbstractUnsignedExtended
└─ AbstractSigned
├─ AbstractSignedFinite
└─ AbstractSignedExtended
Concrete types are constructed via the AIFloat
function and specialized subtypes, parameterized by bit width, significand bits, signedness, and extension.
Key Functions
Generalized Constructor
AIFloat(bits::Int, sigbits::Int; signed::Bool, extended::Bool)
- Instantiates the appropriate AI float concrete type depending on the parameters.
Typed Predicates
is_aifloat(x)
: True ifx
is an AI float type.is_unsigned(x)
,is_signed(x)
,is_finite(x)
,is_extended(x)
: Type properties.
Bit/Value Analysis
- Functions such as
nBits
,nSigBits
,nExpBits
,nMagnitudes
,nValues
, etc., return details about the bit structure and value set for a given type.
Sequences
encoding_sequence
,value_sequence
,foundation_magnitudes
: Enumerate underlying representations and corresponding values.
Julia Support
- Indexing and conversion helpers:
index1
,value_to_index
,index_to_value
,floatleast
,ulp_distance
.
Usage Examples
Constructing a Custom Float Type
using AIFloats
# Create a 16-bit signed, extended (Inf-supporting) float type
T = AIFloat(16, 11; signed=true, extended=true)
# Query some properties
nBits(T) # Number of bits
nFiniteValues(T) # Number of finite representable values
Checking Type Properties
is_signed(T) # true
is_extended(T) # true
Dependencies
Development
The main module includes and organizes its logic across several source files:
type/constants.jl
— type-level constantstype/abstract.jl
— abstract type definitionssupport/indices.jl
— helper functions for indexingconcrete/encodings.jl
— concrete encoding definitionsconcrete/foundation.jl
— foundation logic for concrete typesconcrete/unsigned.jl
andconcrete/signed.jl
— unsigned/signed typessupport/julialang.jl
— Julia language support and integration
License
[Specify your license here.]
Note: For further details, please refer to the individual source files and Julia docstrings as implemented in the codebase.