互联网技术 · 2024年2月29日

在CC++中如何表示绝对值函数

不同类型的数据使用不同类型的绝对值函数:

整型:

int abs(int i) //返回整型参数i的绝对值

1

复数:

double cabs(struct complex znum) //返回复数znum的绝对值

1

双精度浮点型:

double fabs(double x) //返回双精度参数x的绝对值

1

长整型:

long labs(long n) //返回长整型参数n的绝对值

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.