类:Fract16
The Fract16 class represents a 16-bit fractional value, providing utilities for scaling and comparison, with built-in type conversions and operators.
The source file for this class is located in os/framework/Fract16.h.
Constructors
Default Constructor
Fract16(uint16_t value = 0);
Initializes the fractional value. Defaults to 0.
Parameters:
value(uint16_t, optional): The fractional value. Defaults to0.
Constructor with Bit Scaling
Fract16(uint16_t value, uint8_t bits);
Initializes the fractional value with bit scaling.
Parameters:
value(uint16_t): The value to scale.bits(uint8_t): The number of bits to scale from.
Member Functions
to8bits
uint8_t to8bits();
Converts the 16-bit value to 8 bits.
Returns:
uint8_t: The 8-bit representation of the value.
to7bits
uint8_t to7bits();
Converts the 16-bit value to 7 bits.
Returns:
uint8_t: The 7-bit representation of the value.
Operators
Boolean Conversion
operator bool();
Checks if the value is non-zero.
Returns:
bool:trueif the value is greater than0, otherwisefalse.