strtof, strtod, strtold
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <stdlib.h> 中定义
|
||
float strtof( const char* str, char** str_end ); |
||
double strtod( const char* str, char** str_end ); |
||
long double strtold( const char* str, char** str_end ); |
||
解释浮点值一个字节的字符串所指向的
str
.原文:
Interprets a floating point value in a byte string pointed to by
str
.函数丢弃任何空白字符(由std::isspace()),直到找到第一个非空白字符。然后它会尽可能多的字符可能形成一个有效的浮点表示,并将其转换为浮点值。有效浮点值可以是下列之一:
原文:
Function discards any whitespace characters (as determined by std::isspace()) until first non-whitespace character is found. Then it takes as many characters as possible to form a valid floating point representation and converts them to floating point value. The valid floating point value can be one of the following:
- 十进制浮点表达。它由以下几部分组成:原文:decimal floating point expression. It consists of the following parts:
- (可选)加号或减号
- 可以选择一个的小数点字符(定义尾数)包含的小数位数的非空序列原文:nonempty sequence of decimal digits optionally containing a decimal point character (defines significand)
- (可选)
e
或E
可选的负号或加号和非空的十进制数字序列(DEFINES指数)原文:(可选)e
orE
followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent)
-
- 二进制浮点表达。它由以下几部分组成:原文:binary floating point expression. It consists of the following parts:
- (可选)加号或减号
-
0x
or0X
- 可以选择一个的小数点字符(定义尾数)包含十六进制数字的非空序列原文:nonempty sequence of hexadecimal digits optionally containing a decimal point character (defines significand)
- (可选)
p
或P
可选的负号或加号和非空的十六进制数字序列(DEFINES指数)原文:(可选)p
orP
followed with optional minus or plus sign and nonempty sequence of hexadecimal digits (defines exponent)
-
- 无穷的表达。它由以下几部分组成:原文:infinity expression. It consists of the following parts:
- (可选)加号或减号
-
INF
或INFINITY
忽略大小写
-
- 没有一个数的表达。它由以下几部分组成:原文:not-a-number expression. It consists of the following parts:
- (可选)加号或减号
-
NAN
或NAN(
“char_sequence”)
忽略大小写的NAN
部分。 “char_sequence”只能包含字母数字字符。其结果是一个安静的南浮点值.原文:NAN
orNAN(
char_sequence)
ignoring case of theNAN
part. char_sequence can only contain alphanumeric characters. The result is a quiet NaN floating point value.
-
的功能设置的指针所指向的
str_end
指向过去的字符的最后一个字符解释。 str_end
是NULL,被忽视原文:
The functions sets the pointer pointed to by
str_end
to point to the character past the last character interpreted. If str_end
is NULL, it is ignored.目录 |
[编辑] 参数
str | - | null结尾的字节串的指针进行解释
原文: pointer to the null-terminated byte string to be interpreted |
str_end | - | 字符指针的指针.
|
[编辑] 返回值
浮点值对应的成功的内容
str
。如果转换的值落在相应的返回类型的范围,范围发生错误,HUGE_VAL,HUGE_VALF或HUGE_VALL返回。如果没有可以进行转换,0返回.原文:
Floating point value corresponding to the contents of
str
on success. If the converted value falls out of range of corresponding return type, range error occurs and HUGE_VAL, HUGE_VALF or HUGE_VALL is returned. If no conversion can be performed, 0 is returned.[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
一个字节的字符串转换为浮点值 原文: converts a byte string to a floating point value (函数) | |
C++ documentation for strtof, strtod, strtold
|