c语言字符串转数字 nan,nan函数 c语言_nan()函数以及C ++中的示例

nan函数 c语言

C ++ nan()函数 (C++ nan() function)

nan() function is a library function of cmath header, it is used to get the NaN value, it returns a quiet NaN (Not-A-Number) value of double type.

nan()函数是cmath标头的库函数,用于获取NaN值,它返回双精度类型的安静NaN (非数字)值。

Syntax of nan() function:

nan()函数的语法:

nan(const char* tagp);

Parameter(s): const char* tagp – an implementation-specific C-String, it can be an empty string ("") to generate a generic NaNvalue (nan).

参数: const char * tagp –特定于实现的C-String,它可以是空字符串( “” ),以生成通用的NaN值( nan )。

Return value: double – returns the NaN value (nan) of type double.

返回值: double-返回double类型的NaN值( nan )。

Example:

例:

Function call:

nan("");

Output:

nan

C ++代码演示nan()函数的示例 (C++ code to demonstrate the example of nan() function)

// C++ code to demonstrate the example of

// nan() function

#include

#include

using namespace std;

// main() section

int main()

{

double nanValue;

//generating generic NaN value

//by passing an empty string

nanValue = nan("");

//printing the value

cout<

return 0;

}

Output

输出量

nanValue: nan

Example to print the type of NaN ("nan")

打印NaN类型(“ nan”)的示例

In C++, to print the type of a variable or value, we can use typeid() by passing the variable name or the value and the function name() with the statement typeid(variable/value) returns the type of the variable. To use these functions, we must use typeinfo header.

在C ++中,要打印变量或值的类型,我们可以使用typeid(),方法是传递变量名或值,而函数name()与语句typeid(variable / value)一起返回变量的类型。 要使用这些功能,我们必须使用typeinfo标头。

Consider this example,

考虑这个例子,

// C++ code to demonstrate the example of

// nan() function & printing the return type of nan()

#include

#include

#include      //for types related functions

using namespace std;

// main() section

int main()

{

double nanValue;

//generating generic NaN value

//by passing an empty string

nanValue = nan("");

//printing the value

cout<

//printing the type of nan

cout<

return 0;

}

Output

输出量

nanValue: nan

type of nan: d

See the output – type of nan is d that is used for the double.

查看输出-nan的类型是d ,它用于double。

Reference: C++ nan() function

参考: C ++ nan()函数

翻译自: https://www.includehelp.com/cpp-tutorial/nan-function-with-example.aspx

nan函数 c语言

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值