std::strtof, std::strtod, std::strtold
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <cstdlib>
|
||
| float strtof( const char* str, char** str_end ); |
(C++11 起) | |
| double strtod( const char* str, char** str_end ); |
||
| long double strtold( const char* str, char** str_end ); |
(C++11 起) | |
。解释浮点值一个字节的字符串所指向的
str.Original:
Interprets a floating point value in a byte string pointed to by
str.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
函数丢弃任何空白字符(由std::isspace()),直到找到第一个非空白字符。然后它会尽可能多的字符可能形成一个有效的浮点表示,并将其转换为浮点值。有效浮点值可以是下列之一:
Original:
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:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- 十进制浮点表达。它由以下几部分组成:Original:decimal floating point expression. It consists of the following parts:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- (可选的)加号或减号Original:(可选的) plus or minus signThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 可以选择一个的小数点字符(定义尾数)包含的小数位数的非空序列Original:nonempty sequence of decimal digits optionally containing a decimal point character (defines significand)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - (可选的)
e或E可选的负号或加号和非空的十进制数字序列(DEFINES指数)Original:(可选的)eorEfollowed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
- 二进制浮点表达。它由以下几部分组成:Original:binary floating point expression. It consists of the following parts:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- (可选的)加号或减号Original:(可选的) plus or minus signThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
0xor0X - 可以选择一个的小数点字符(定义尾数)包含十六进制数字的非空序列Original:nonempty sequence of hexadecimal digits optionally containing a decimal point character (defines significand)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - (可选的)
p或P可选的负号或加号和非空的十六进制数字序列(DEFINES指数)Original:(可选的)porPfollowed with optional minus or plus sign and nonempty sequence of hexadecimal digits (defines exponent)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
- 无穷的表达。它由以下几部分组成:Original:infinity expression. It consists of the following parts:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- (可选的)加号或减号Original:(可选的) plus or minus signThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
INF或INFINITY忽略大小写Original:INForINFINITYignoring caseThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
- 没有一个数的表达。它由以下几部分组成:Original:not-a-number expression. It consists of the following parts:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- (可选的)加号或减号Original:(可选的) plus or minus signThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
NAN或NAN(“char_sequence”)忽略大小写的NAN部分。 “char_sequence”只能包含字母数字字符。其结果是一个安静的南浮点值.Original:NANorNAN(char_sequence)ignoring case of theNANpart. char_sequence can only contain alphanumeric characters. The result is a quiet NaN floating point value.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
。的功能设置的指针所指向的
str_end指向过去的字符的最后一个字符解释。 str_end是NULL,被忽视。Original:
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.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 。参数。
| str | - | 。 null结尾的字节串的指针进行解释。
Original: pointer to the null-terminated byte string to be interpreted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| str_end | - | 。字符指针的指针.
Original: pointer to a pointer to character. The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
===。 返回值。===
。浮点值对应的成功的内容
str。如果转换的值落在相应的返回类型的范围,范围发生错误,HUGE_VAL,HUGE_VALF或HUGE_VALL返回。如果没有可以进行转换,0返回.Original:
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.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 。为例。
| 本节是不完整的 原因: no example |
[编辑] 。另请参阅。
| 一个字节的字符串转换为浮点值 Original: converts a byte string to a floating point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
| C documentation for strtof, strtod, strtold
| |