STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Static Public Member Functions | List of all members
stt::data::PrecisionUtil Class Reference

Responsible for floating-point precision processing. More...

#include <sttnet_English.h>

Static Public Member Functions

static std::string & getPreciesFloat (const float &number, const int &bit, std::string &str)
 Format a floating-point number into a string representation with a specified number of decimal places. More...
 
static float & getPreciesFloat (float &number, const int &bit)
 Retain a specified number of decimal places for a float value and modify the original value directly. More...
 
static std::string & getPreciesDouble (const double &number, const int &bit, std::string &str)
 Format a double-precision floating-point number into a string representation with a specified number of decimal places. More...
 
static double & getPreciesDouble (double &number, const int &bit)
 Retain a specified number of decimal places for a double value and modify the original value directly. More...
 
static float & getValidFloat (float &number, const int &bit)
 Dynamically adjust the decimal precision based on the value, retaining a specified number of significant figures. More...
 

Detailed Description

Responsible for floating-point precision processing.

Member Function Documentation

static std::string& stt::data::PrecisionUtil::getPreciesDouble ( const double &  number,
const int &  bit,
std::string &  str 
)
static

Format a double-precision floating-point number into a string representation with a specified number of decimal places.

Parameters
numberInput double value.
bitNumber of decimal places to retain.
strUsed to store the formatted string.
Returns
Reference to the formatted result string.
static double& stt::data::PrecisionUtil::getPreciesDouble ( double &  number,
const int &  bit 
)
static

Retain a specified number of decimal places for a double value and modify the original value directly.

Parameters
numberDouble variable to be processed (will be modified).
bitNumber of decimal places to retain.
Returns
Reference to the modified double.
static std::string& stt::data::PrecisionUtil::getPreciesFloat ( const float &  number,
const int &  bit,
std::string &  str 
)
static

Format a floating-point number into a string representation with a specified number of decimal places.

Parameters
numberInput floating-point number.
bitNumber of decimal places to retain.
strUsed to store the formatted string.
Returns
Reference to the formatted result string.
static float& stt::data::PrecisionUtil::getPreciesFloat ( float &  number,
const int &  bit 
)
static

Retain a specified number of decimal places for a float value and modify the original value directly.

Parameters
numberFloat variable to be processed (will be modified).
bitNumber of decimal places to retain.
Returns
Reference to the modified float.
static float& stt::data::PrecisionUtil::getValidFloat ( float &  number,
const int &  bit 
)
static

Dynamically adjust the decimal precision based on the value, retaining a specified number of significant figures.

For decimals less than 1, the position of the most significant digit is first determined, and then bit significant figures are retained on this basis. The modified value will be rounded to retain the appropriate number of decimal places and written back to the original variable.

Parameters
numberFloat value to be processed (will be modified).
bitNumber of significant figures to retain.
Returns
Reference to the modified float.

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