Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Burger::uint32_float_t Union Reference

Union to create float values with integer constants. More...

Public Member Functions

 operator float () const noexcept
 Accessor to load the floating point value.
 
uint32_float_toperator= (float fInput) noexcept
 Update with a new floating point value.
 
float get_float (void) const noexcept
 Accessor to load the 32 float.
 
void set_float (float fInput) noexcept
 Set the floating point value with a binary representation in a float.
 
uint32_t get_uint32 (void) const noexcept
 Accessor to load the 32 bit value in binary.
 
void set_uint32 (uint32_t uInput) noexcept
 Set the floating point value with a binary representation in an integer.
 

Public Attributes

uint32_t w
 Value in binary.
 
float f
 Value as a 32 bit float.
 

Detailed Description

Union to create float values with integer constants.


Some "C" compilers are not 100% accurate in creating floating point constants. To get around this limitation, once the binary representation of a floating point number is determined, it will be used to assign the value so the binary representation does not change from compiler to compiler.

This union is also used to obtain the binary representation of a 32 bit float in a cross compiler way.

// Binary representation for Single Epsilon
void code(void)
{
// Fetch as a float
float fEpsilon = Epsilon;
// Set a new floating point value
Epsilon = 1.5f;
// Get the binary value as a 32 bit integer
uint32_t uEpsilon = Epsilon.get_uint32();
// Set the binary value as a 32 bit integer
Epsilon.set_uint32(0x34000000U);
}
Select a type based if the conditional is true or false.
Definition burger.h:3178
Union to create float values with integer constants.
Definition burger.h:1753
See also
uint64_double_t

Member Function Documentation

◆ get_float()

Burger::uint32_float_t::get_float ( void ) const
inlinenoexcept

Accessor to load the 32 float.


Returns
Floating point value
See also
get_uint32(void) const

◆ get_uint32()

Burger::uint32_float_t::get_uint32 ( void ) const
inlinenoexcept

Accessor to load the 32 bit value in binary.


Returns
Floating point value as a binary representation in an integer
See also
set_uint32(uint32_t)

◆ operator float()

Burger::uint32_float_t::operator float ( ) const
inlinenoexcept

Accessor to load the floating point value.


See also
uint32_float_t::operator = (float)

◆ operator=()

Burger::uint32_float_t::operator= ( float fInput)
inlinenoexcept

Update with a new floating point value.


Parameters
fInput32 bit floating point number to store in the union
See also
uint32_float_t::operator float() const

◆ set_float()

Burger::uint32_float_t::set_float ( float fInput)
inlinenoexcept

Set the floating point value with a binary representation in a float.


Parameters
fInput32 bit float to store in the union
See also
set_uint32(uint32_t)

◆ set_uint32()

Burger::uint32_float_t::set_uint32 ( uint32_t uInput)
inlinenoexcept

Set the floating point value with a binary representation in an integer.


Parameters
uInput32 bit integer to store in the union
See also
get_uint32(void) const

Member Data Documentation

◆ f

float Burger::uint32_float_t::f

Value as a 32 bit float.

◆ w

uint32_t Burger::uint32_float_t::w

Value in binary.