---
title: fp16_t
description: "本章接口为预留接口，后续有可能变更或废弃，不建议开发者使用，开发者无需关注。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/aolapi/atlasascendc_api_07_1108.html
sourcePath: /source/zh/canncommercial/900/API/aolapi/atlasascendc_api_07_1108.html
indexId: eea0ed064b90ad198ddffdc03f204995565cac09922d2784f9aa5c0eb66f172370
---
# fp16_t

本章接口为预留接口，后续有可能变更或废弃，不建议开发者使用，开发者无需关注。


**表1 接口列表**

| 接口定义 | 功能说明 |
| --- | --- |
| tagFp16(void) | fp16\_t的默认构造函数且不带任何参数。 |
| tagFp16(const T &value) | fp16\_t的构造函数且有一个可以是任何数据类型的参数。 |
| tagFp16(const bfloat16& value) | fp16\_t的构造函数且有一个bfloat16数据类型参数。 |
| tagFp16(const uint16\_t &uiVal) | fp16\_t的构造函数且有一个uint16\_t数据类型参数。 |
| tagFp16(const tagFp16 &fp) | fp16\_t的构造函数且有一个fp16\_t数据类型参数（拷贝构造函数）。 |
| float() | 重写转换运算符以将fp16\_t转换为float（fp32）。 |
| bfloat16() | 重写转换运算符以将fp16\_t转换为bfloat16。 |
| double() | 重写转换运算符以将fp16\_t转换为double（fp64）。 |
| int8\_t() | 重写转换运算符以将fp16\_t转换为int8\_t。 |
| uint8\_t() | 重写转换运算符以将fp16\_t转换为uint8\_t。 |
| int16\_t() | 重写转换运算符以将fp16\_t转换为int16\_t。 |
| uint16\_t() | 重写转换运算符以将fp16\_t转换为uint16\_t。 |
| int32\_t() | 重写转换运算符以将fp16\_t转换为int32\_t。 |
| uint32\_t() | 重写转换运算符以将fp16\_t转换为uint32\_t。 |
| int64\_t() | 重写转换运算符以将fp16\_t转换为int64\_t。 |
| uint64\_t() | 重写转换运算符以将fp16\_t转换为uint64\_t。 |
| bool() | 重写转换运算符以将fp16\_t转换为bool。 |
| IsInf() | 判断fp16\_t数值是不是无穷的，正无穷返回1，负无穷返回\-1，否则返回0。 |
| toFloat() | 将fp16\_t转换为float（fp32）。 |
| toDouble() | 将fp16\_t转换为double（fp64）。 |
| toInt8() | 将fp16\_t转换为int8\_t。 |
| toUInt8() | 将fp16\_t转换为uint8\_t。 |
| toInt16() | 将fp16\_t转换为int16\_t。 |
| toUInt16() | 将fp16\_t转换为uint16\_t。 |
| toInt32() | 将fp16\_t转换为int32\_t。 |
| toUInt32() | 将fp16\_t转换为uint32\_t。 |
| ExtractFP16(const uint16\_t &val, uint16\_t \*s, int16\_t \*e, uint16\_t \*m) | 提取fp16\_t对象的符号、指数和尾数。 |
| ReverseMan(bool negative, T \*man) | 当符号位是负数，计算尾数的补码。 |
| MinMan(const int16\_t &ea, T \*ma, const int16\_t &eb, T \*mb) | 选择指数小于另一个指数的尾数右移。 |
| RightShift(T man, int16\_t shift) | 尾数右移shift位。 |
| GetManSum(int16\_t ea, const T &ma, int16\_t eb, const T &mb) | 获取两个fp16\_t数的尾数和，T支持类型：uint16\_t/uint32\_t/uint64\_t。 |
| ManRoundToNearest(bool bit0, bool bit1, bool bitLeft, T man, uint16\_t shift = 0) | 将fp16\_t或float尾数舍入为最接近的值。 |
| GetManBitLength(T man) | 获取浮点数尾数的位长度。 |
| isnan(op::fp16\_t value) | 判断数值是不是无法表示(Not a Number)。 |
