共用方式為


frexp

取得尾數和指數的浮點數。

double frexp(
   double x,
   int *expptr 
);
float frexp(
   float x,
   int * expptr
);  // C++ only
long double frexp(
   long double x,
   int * expptr
);  // C++ only

參數

  • x
    浮點值。

  • expptr
    預存的整數指數的指標。

傳回值

frexp傳回假數。 如果x為 0,則函數會傳回 0,尾數和指數。 如果expptr是NULL,如所述,無效的參數處理常式被叫用參數驗證。 如果執行,則允許繼續執行,這個函式會將errno到EINVAL ,並傳回 0。

備註

frexp函式會分解的浮點數值 (x) 的尾數為 (m) 和指數 (n),以致數值的絕對值m大於或等於 0.5 且小於 1.0 和x = m* 2n。 整數指數n儲存在所指位置expptr。

C + + 允許多載化,因此您可以呼叫多載的frexp。 在某 c 程式, frexp永遠會接受 double 和一個整數,並傳回 double。

需求

Function

所需的標頭

frexp

<math.h>

其他的相容性資訊,請參閱相容性在簡介中。

範例

// crt_frexp.c
// This program calculates frexp( 16.4, &n )
// then displays y and n.
 

#include <math.h>
#include <stdio.h>

int main( void )
{
   double x, y;
   int n;

   x = 16.4;
   y = frexp( x, &n );
   printf( "frexp( %f, &n ) = %f, n = %d\n", x, y, n );
}
  

.NET Framework 對等用法

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

請參閱

參考

浮點支援

ldexp

modf modff