STTNet 0.7.0
Loading...
Searching...
No Matches
stt::data::PrecisionUtil Class Reference

负责浮点数精度处理 More...

#include <sttnet.h>

Static Public Member Functions

static std::string & getPreciesFloat (const float &number, const int &bit, std::string &str)
 将浮点数格式化为指定小数位数的字符串表示。
 
static float & getPreciesFloat (float &number, const int &bit)
 将 float 数值保留指定位数的小数,并直接修改原值。
 
static std::string & getPreciesDouble (const double &number, const int &bit, std::string &str)
 将双精度浮点数格式化为指定小数位数的字符串表示。
 
static double & getPreciesDouble (double &number, const int &bit)
 将 double 数值保留指定位数的小数,并直接修改原值。
 
static float & getValidFloat (float &number, const int &bit)
 根据数值动态调整小数精度,保留指定数量的有效数字。
 

Detailed Description

负责浮点数精度处理

Member Function Documentation

◆ getPreciesDouble() [1/2]

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

将双精度浮点数格式化为指定小数位数的字符串表示。

Parameters
number输入的 double 数值。
bit保留的小数位数。
str用于存储格式化后的字符串。
Returns
格式化结果字符串的引用。

◆ getPreciesDouble() [2/2]

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

将 double 数值保留指定位数的小数,并直接修改原值。

Parameters
number待处理的 double 变量(将被修改)。
bit保留的小数位数。
Returns
修改后的 double 引用。

◆ getPreciesFloat() [1/2]

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

将浮点数格式化为指定小数位数的字符串表示。

Parameters
number输入的浮点数。
bit保留的小数位数。
str用于存储格式化后的字符串。
Returns
格式化结果字符串的引用。

◆ getPreciesFloat() [2/2]

static float & stt::data::PrecisionUtil::getPreciesFloat ( float & number,
const int & bit )
static

将 float 数值保留指定位数的小数,并直接修改原值。

Parameters
number待处理的 float 变量(将被修改)。
bit保留的小数位数。
Returns
修改后的 float 引用。

◆ getValidFloat()

static float & stt::data::PrecisionUtil::getValidFloat ( float & number,
const int & bit )
static

根据数值动态调整小数精度,保留指定数量的有效数字。

对于小于 1 的小数,会先确定其最前位有效数字所处的位置, 然后在此基础上保留 bit 位有效数字。 修改后的数值将四舍五入保留合适的小数位,并写回原变量。

Parameters
number待处理的 float 数值(将被修改)。
bit希望保留的有效数字位数。
Returns
修改后的 float 引用。

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