floatFractionalBits
Returns the number of fractional bits in the mantissa of floating point type T.
Function parameters
Parameters
- T:type
Functions in this namespace
Functions
- floatExponentBits
- Returns the number of bits in the exponent of floating point type T.
- floatMantissaBits
- Returns the number of bits in the mantissa of floating point type T.
- floatFractionalBits
- Returns the number of fractional bits in the mantissa of floating point type T.
- floatExponentMin
- Returns the minimum exponent that can represent
- floatExponentMax
- Returns the maximum exponent that can represent
- floatTrueMin
- Returns the smallest subnormal number representable in floating point type T.
- floatMin
- Returns the smallest normal number representable in floating point type T.
- floatMax
- Returns the largest normal number representable in floating point type T.
- floatEps
- Returns the machine epsilon of floating point type T.
- floatEpsAt
- Returns the local epsilon of floating point type T.
- inf
- Returns the inf value for a floating point `Type`.
- nan
- Returns the canonical quiet NaN representation for a floating point `Type`.
- snan
- Returns a signalling NaN representation for a floating point `Type`.
Source
Implementation
pub inline fn floatFractionalBits(comptime T: type) comptime_int {
comptime assert(@typeInfo(T) == .float);
// standard IEEE floats have an implicit 0.m or 1.m integer part
// f80 is special and has an explicitly stored bit in the MSB
// this function corresponds to `MANT_DIG - 1' from C
return switch (@typeInfo(T).float.bits) {
16 => 10,
32 => 23,
64 => 52,
80 => 63,
128 => 112,
else => @compileError("unknown floating point type " ++ @typeName(T)),
};
}