frexp ()- 独立浮点值

格式

#include <math.h>
double frexp(double x, int *expptr);

语言级别

ANSI

线程安全

描述

frexp() 函数将浮点值 x 分解为一个术语 m (对于 mantissa) 和另一个术语 n (对于指数)。 执行此操作时, x=m*2 n,并且 m 的绝对值大于或等于 0.5 且小于 1.0 或等于 0frexp() 函数将整数指数 n 存储在 expptr 指向的位置。

返回值

frexp() 函数返回 mantissa 术语 m。 如果 x0,那么 frexp() 将针对尾数和指数返回 0 。 尾数与自变量 x具有相同的符号。 frexp() 函数的结果不能包含范围错误。

示例

此示例将 x 16.4的浮点值分隔为其尾数 0.5125及其指数 5。 它将 mantissa 存储在 y 中,并将指数存储在 n中。
#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x, m;
   int n;
 
   x = 16.4;
   m = frexp(x, n);
 
   printf("The mantissa is %lf and the exponent is %d\n", m, n);
}
 
/*******************  Output should be similar to:  ***************
 
The mantissa is 0.512500 and the exponent is 5
*/

相关信息