负责浮点数精度处理
More...
#include <sttnet.h>
|
| 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) |
| | 根据数值动态调整小数精度,保留指定数量的有效数字。
|
| |
◆ 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: