Float8E4M3

Structs · AiDotNet.MixedPrecision

Represents an 8-bit floating point number in E4M3 format (4 exponent bits, 3 mantissa bits).

Inheritance: ValueType → Float8E4M3

Implements: IComparable<Float8E4M3>, IEquatable<Float8E4M3>

For Beginners

E4M3 is like a compressed version of regular floating point numbers. It uses only 8 bits (1 byte) instead of 32 bits, making it 4x smaller. The trade-off is reduced precision and range.

How It Works

Format Details:

  • 1 sign bit
  • 4 exponent bits (bias = 7)
  • 3 mantissa bits
  • Range: ±448
  • Smallest positive: ~0.001953125

Use Cases: Best for weights and activations in neural network forward passes where values are typically well-bounded.

Hardware: NVIDIA H100/H200 GPUs have native FP8 Tensor Cores that can process E4M3 values at 2x the throughput of FP16.

Properties

Property Summary
bool IsNaN { get; } Returns true if this value is NaN.
bool IsNegative { get; } Returns true if this value is negative.
bool IsZero { get; } Returns true if this value is zero.
byte RawValue { get; } Gets the raw byte value.

Methods

Method Summary
Float8E4M3 FromFloat(float value) Creates a Float8E4M3 from a single-precision float.
Float8E4M3 op_Explicit(float value)
bool Equals(Float8E4M3 other)
bool Equals(object obj)
bool op_Equality(Float8E4M3 left, Float8E4M3 right)
bool op_GreaterThan(Float8E4M3 left, Float8E4M3 right)
bool op_GreaterThanOrEqual(Float8E4M3 left, Float8E4M3 right)
bool op_Inequality(Float8E4M3 left, Float8E4M3 right)
bool op_LessThan(Float8E4M3 left, Float8E4M3 right)
bool op_LessThanOrEqual(Float8E4M3 left, Float8E4M3 right)
float ToFloat() Converts this Float8E4M3 to a single-precision float.
float op_Explicit(Float8E4M3 value)
int CompareTo(Float8E4M3 other)
int GetHashCode()
string ToString()

Fields

Field Summary
Float8E4M3 MaxValue Maximum representable value in E4M3 format (448).
Float8E4M3 MinPositive Minimum representable positive value in E4M3 format.
Float8E4M3 NaN Represents NaN (Not a Number).
Float8E4M3 One Represents positive one.
Float8E4M3 Zero Represents positive zero.