---
title: nan
description: "返回输入要求的浮点nan。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0212.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0212.html
indexId: 2cc02f172eea32d17bc86034d7e8d5f3aa95622cc594419b64d7e5b6d2d4fdde61
---
# nan

返回输入要求的浮点nan。

#### 接口定义

C interface：

float nanf(const char *tagp);

double nan(const char *tagp);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| tagp | 在nanf中，tagp是字符串指针类型。 在nan中，tagp是字符串指针类型。 | 表示输入数据。 | 输入 |


#### 返回值

当tagp不为NULL时，返回浮点NAN，如果为NULL，则出现未定义行为，调用者需保证入参不为NULL。


#### 依赖

C: "km.h"


#### 示例

C interface：

```
// typical usage
const char *a = "0x7ff8000000000000";
const char *b = "0x781";
const char *c = "0x781asdf";
printf("/*\n");
printf(" * nan(%s)=0x%lx\n", a, Asuint64(nan(a)));
printf(" * nan(%s)=0x%lx\n", b, Asuint64(nan(b)));
printf(" * nan(%s)=0x%lx\n", c, Asuint64(nan(c)));
printf(" **/\n");
/*
 * nan(0x7ff8000000000000)=0x7ff8000000000000
 * nan(0x781)=0x7ff8000000000781
 * nan(0x781asdf)=0x7ff8000000000000
 **/
```
