DSC Engine
All Classes Files Functions Variables Typedefs
Public Member Functions | List of all members
DSC::sf24 Class Reference

24-bit (16.8) signed fixed floating point number More...

#include <sf24.hpp>

Public Member Functions

 sf24 (short x)
 Implicit s16 to sf24 conversion. More...
 
 sf24 (short x, unsigned char frac)
 Builds a signed fixed number from its separate integral and fractional part. More...
 
short get_int () const
 Gets integral part of number. More...
 
unsigned char get_frac () const
 Gets fractional part of number. More...
 
sf24 operator+ (const sf24 &b) const
 
sf24 operator- (const sf24 &b) const
 
sf24 operator* (const sf24 &b) const
 
sf24 operator- () const
 
sf24operator+= (const sf24 &b)
 
sf24operator-= (const sf24 &b)
 
 operator int () const
 Explicit narrowing conversion to integral type (only the integral type is kept) More...
 
 operator short () const
 Explicit narrowing conversion to short integral type (only the integral type is kept) More...
 
bool operator< (const sf24 &b) const
 
bool operator> (const sf24 &b) const
 
bool operator<= (const sf24 &b) const
 
bool operator>= (const sf24 &b) const
 
bool operator== (const sf24 &b) const
 
bool operator!= (const sf24 &b) const
 
bool in_range (const sf24 &min, const sf24 &max) const
 Checks if the number belongs to an interval. More...
 
char * to_string () const
 
sf24 abs () const
 

Detailed Description

24-bit (16.8) signed fixed floating point number

Constructor & Destructor Documentation

◆ sf24() [1/2]

DSC::sf24::sf24 ( short  x)

Implicit s16 to sf24 conversion.

Parameters
[in]xshort number to be converted to sf24

◆ sf24() [2/2]

DSC::sf24::sf24 ( short  x,
unsigned char  frac 
)

Builds a signed fixed number from its separate integral and fractional part.

Parameters
[in]xnumber integral part
[in]fracnumber fractional part

Member Function Documentation

◆ get_frac()

unsigned char DSC::sf24::get_frac ( ) const

Gets fractional part of number.

Returns
number fractional part scaled to 256 and rounded to a full byte (128 = 0.5)

◆ get_int()

short DSC::sf24::get_int ( ) const

Gets integral part of number.

Returns
number integral part

◆ in_range()

bool DSC::sf24::in_range ( const sf24 min,
const sf24 max 
) const

Checks if the number belongs to an interval.

Parameters
[in]minminimum target value
[in]maxmaximum target value
Returns
true if the number is between the specified values, false otherwise

◆ operator int()

DSC::sf24::operator int ( ) const
explicit

Explicit narrowing conversion to integral type (only the integral type is kept)

Usage

sf24 x {12, 128}; // x = 12.5
int y = (int)x; // y = 12
24-bit (16.8) signed fixed floating point number
Definition: sf24.hpp:13

◆ operator short()

DSC::sf24::operator short ( ) const
explicit

Explicit narrowing conversion to short integral type (only the integral type is kept)

Usage

sf24 x {12, 128}; // x = 12.5
short y = (short)x; // y = 12

The documentation for this class was generated from the following file: