---
title: 函数说明
description: "KML_MATH是C语言实现的基本数学函数库。其中，高性能版本(libkm.so)计算结果对标开源数学库MPFR，高精度版本(libkm_l9.so)计算结果对标x86数学库。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0112.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0112.html
indexId: e044bc58644dc2177f5f95958716b72e881af872cef469f3be83335d715bc37a76
---
# 函数说明

KML_MATH是C语言实现的基本数学函数库。其中，高性能版本(libkm.so)计算结果对标开源数学库MPFR，高精度版本(libkm_l9.so)计算结果对标x86数学库。

| 函数类 | 函数名 | 描述 | 高性能版本 | 高精度版本 |
| --- | --- | --- | --- | --- |
| 三角函数 （Trigonometric functions） | sin | 正弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | sind | 正弦函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | sinpi | 正弦函数（求入参乘以π的正弦值）。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | cos | 余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | cosd | 余弦函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | cospi | 余弦函数（求入参乘以π的余弦值）。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | sincos | 正弦、余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | sincosd | 正弦余弦函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | tan | 正切函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | tand | 正切函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | tanpi | 正切函数（求入参乘以π的正切值）。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | asin | 反正弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | asind | 反正弦函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | asinpi | 反正弦函数/π。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | acos | 反余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | acosd | 反余弦函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | acospi | 反余弦函数/π。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | atan | 反正切函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | atand | 反正切函数（出参为角度）。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | atanpi | 反正切函数/π。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | atan2 | 反正切函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | atan2d/atand2 | 反正切函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | atan2pi | 反正切函数/π。 | 实数单精度/双精度 | 无 |
| 三角函数 （Trigonometric functions） | cot | 余切函数（入参为弧度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 三角函数 （Trigonometric functions） | cotd | 余切函数（入参为角度）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 双曲函数 （Hyperbolic functions） | sinh | 双曲正弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 双曲函数 （Hyperbolic functions） | cosh | 双曲余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 双曲函数 （Hyperbolic functions） | sinhcosh | 双曲正弦、余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度 |
| 双曲函数 （Hyperbolic functions） | tanh | 双曲正切函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 双曲函数 （Hyperbolic functions） | asinh | 反双曲正弦函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 双曲函数 （Hyperbolic functions） | acosh | 反双曲余弦函数。 | 实数单精度/双精度 | 实数单精度/双精度 |
| 双曲函数 （Hyperbolic functions） | atanh | 反双曲正切函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | exp | 指数函数（base e）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | exp2 | 指数函数（base 2）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | exp10 | 指数函数（base 10）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | expm1 | 指数函数（e^x \- 1）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | frexp | 将x转换为归一化[1/2, 1)的有符号数乘以2的积分幂。 | 无 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | ldexp | 指数函数（x \* 2^exp）。 | 无 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | log | 对数函数（base e）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | log2 | 对数函数（base 2）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | log10 | 对数函数（base 10）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | log1p | 对数函数，即ln(1+x)的值。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | logb | 对数函数，求x的指数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | ilogb | 计算x的指数，返回整型结果。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | scalb | 求x\*(2^y)，y为浮点类型。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | scalbln | 求x\*(2^y)，y为长整型。 | 无 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | scalbn | 求x\*(2^y)，y为整型。 | 无 | 实数单精度/双精度/长双精度 |
| 指数和对数函数 （Exponential and logarithmic functions） | hypot | 求(x^2 + y^2)的开方。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 幂和根函数（Power and root function） | pow | 幂函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 幂和根函数（Power and root function） | powr?i? | 幂函数。 | 无 | 实数单精度/双精度/长双精度 |
| 幂和根函数（Power and root function） | powi?i? | 幂函数。 | 无 | 实数整型/长整型 |
| 幂和根函数（Power and root function） | pow2o3 | 幂函数（幂值2/3）。 | 实数单精度/双精度 | 无 |
| 幂和根函数（Power and root function） | pow3o2 | 幂函数（幂值3/2）。 | 实数单精度/双精度 | 无 |
| 幂和根函数（Power and root function） | powr | 幂函数（x>0）。 | 实数单精度/双精度 | 无 |
| 幂和根函数（Power and root function） | sqrt | 平方根函数。 | 实数单精度/双精度/长双精度 | 实数单精度/双精度/长双精度 |
| 幂和根函数（Power and root function） | invsqrt | 求平方根的倒数（）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 幂和根函数（Power and root function） | cbrt | 立方根函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 杂项函数（Miscellaneous Functions） | fabs | 计算浮点数绝对值。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | fdim | 如果x<=y，则fdim函数返回零值；否则返回x\-y的值。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | fmax | 返回入参的最大值。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | fmaxmag | 返回绝对值相对较大的入参，否则行为类似于fmax(x,y)。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | fmin | 返回入参的最小值。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | fminmag | 返回绝对值相对较小的入参，否则行为类似于fmin(x,y)。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | nan | 返回输入要求的浮点nan。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | nextafter | 在y方向上，以指定格式返回x之后的下一个可表示值。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | nexttoward | 返回x在y方向的下个浮点数。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | significand | 求x的有效数字。 | 实数单精度/双精度 | 无 |
| 杂项函数（Miscellaneous Functions） | finite | 判断x是否为有限数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | annuity | 求年金现值系数（）。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | compound | 计算复利终值系数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | erf | 误差函数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 特殊函数（Special Function） | erfc | 互补误差函数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | erfcx | 互补误差函数与的乘积。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | erfinv | 逆误差函数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | gamma | 计算x的伽马值绝对值的自然对数。 | 实数单精度/双精度 | 实数单精度/双精度 |
| 特殊函数（Special Function） | gamma\_r | 计算x的伽马值绝对值的自然对数，返回伽马值的符号。 | 实数单精度/双精度 | 实数双精度 |
| 特殊函数（Special Function） | lgamma | 计算x的伽马值绝对值的自然对数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | lgamma\_r | 计算x的伽马值绝对值的自然对数，返回伽马值的符号。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | tgamma | 计算x的伽马值。 | 实数单精度/双精度 | 实数单精度/双精度 |
| 特殊函数（Special Function） | j0 | Bessel 0阶第一类函数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | j1 | Bessel 1阶第一类函数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | jn | Bessel n阶第一类函数。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | y0 | Bessel 0阶第二类函数，x > 0。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | y1 | Bessel 1阶第二类函数，x > 0。 | 实数单精度/双精度 | 无 |
| 特殊函数（Special Function） | yn | Bessel n阶第二类函数，x > 0。 | 实数单精度/双精度 | 无 |
| 舍入函数（Nearest Integer Functions） | ceil | 向上舍入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | floor | 向下舍入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | llrint | 基于当前舍入策略四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | llround | 四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | lrint | 基于当前舍入策略四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | lround | 四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | modf | 获取浮点数的整数和小数部分。 | 无 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | nearbyint | 四舍五入取偶。 | 实数单精度/双精度 | 实数单精度/双精度 |
| 舍入函数（Nearest Integer Functions） | rint | 基于当前舍入策略四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | round | 四舍五入。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 舍入函数（Nearest Integer Functions） | trunc | 向0取整。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 取余函数（Remainder Functions） | drem | 计算x / y的余数。 | 实数单精度/双精度 | 无 |
| 取余函数（Remainder Functions） | fmod | 求余数(x\-ny)。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 取余函数（Remainder Functions） | remainder | 求余数（IEEE标准）。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 取余函数（Remainder Functions） | remquo | 求商和余数。 | 实数单精度/双精度 | 实数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cabs | 复数的绝对值。 | 实数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cacos | 复数形式的反余弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | cacosh | 复数形式的反双曲余弦函数。 | 复数单精度/双精度 | 无 |
| 复数函数（Complex Functions） | carg | 返回复数的极坐标形式的角度值。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | casin | 复数形式的反正弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | casinh | 复数形式的反双曲正弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | catan | 复数形式的反正切函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | catanh | 计算复数的双曲正切值。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | ccos | 复数形式的余弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | ccosh | 复数形式的双曲余弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | cdiv | 复数除法。 | 无 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | cexp | 复数形式的指数函数（base e）。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cexp2 | 复数形式的指数函数（base 2）。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cexp10 | 复数形式的指数函数（base 10）。 | 复数单精度/双精度 | 无 |
| 复数函数（Complex Functions） | cimag | 复数的虚部。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cis | 复数的形式返回x的sin/cos值。 | 复数单精度/双精度 | 无 |
| 复数函数（Complex Functions） | cisd | 复数的形式返回x的sin/cos值（入参为角度）。 | 复数单精度/双精度 | 无 |
| 复数函数（Complex Functions） | clog | 复数形式的对数函数（base e）。 | 复数单精度/双精度 | 复数双精度/长双精度 |
| 复数函数（Complex Functions） | clog2 | 复数形式的对数函数（base 2）。 | 复数单精度/双精度 | 无 |
| 复数函数（Complex Functions） | clog10 | 复数形式的对数函数（base 10）。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | conj | 复数z的共轭。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cpow | 复数形式的幂函数。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | cproj | 复数在黎曼球面的投影。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | creal | 复数的实部。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | csin | 复数形式的正弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | csinh | 复数形式的双曲正弦函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | csqrt | 复数形式的平方根函数。 | 复数单精度/双精度 | 复数单精度/双精度/长双精度 |
| 复数函数（Complex Functions） | ctan | 复数形式的正切函数。 | 复数单精度/双精度 | 复数单精度/双精度 |
| 复数函数（Complex Functions） | ctanh | 复数形式的双曲正切函数。 | 复数单精度/双精度 | 无 |
