Share via


scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl

將浮點數乘以 的整數乘冪 FLT_RADIX

語法

double scalbn(
   double x,
   int exp
);
float scalbn(
   float x,
   int exp
);  // C++ only
long double scalbn(
   long double x,
   int exp
);  // C++ only
float scalbnf(
   float x,
   int exp
);
long double scalbnl(
   long double x,
   int exp
);

#define scalbn(X, INT) // Requires C11 or higher

double scalbln(
   double x,
   long exp
);

float scalblnf(
   float x,
   long exp
);
long double scalblnl(
   long double x,
   long exp
);

#define scalbln(X, LONG) // Requires C11 or higher

float scalbln(
   float x,
   long exp
);  // C++ only
long double scalbln(
   long double x,
   long exp
);  // C++ only

參數

x
浮點值。

exp
整數指數。

傳回值

若成功,scalbn 函式會傳回 x * FLT_RADIXexp 的值。 在溢位時(視 的 x 正負號而定), scalbn 會傳回 +/- HUGE_VAL ; errno 值會設定為 ERANGE

如需和可能錯誤傳回值的詳細資訊 errno ,請參閱 errno_doserrno_sys_errlist_sys_nerr

備註

FLT_RADIX在 float.h > 中 < 定義為原生浮點基數;在二進位系統上,其值為 2,且 scalbn 相當於 ldexp

因為 C++ 允許多載,因此您可以呼叫 scalbn 和 多載來取得和 scalbln 傳回 floatlong double 型別。 在 C 程式中,除非您使用 < tgmath.h > 宏來呼叫此函式, scalbn 請一律採用 doubleint ,並傳回 double ,而且 scalbln 一律接受 doublelong 並傳 double 回 。

如果您使用 < tgmath.h >scalbn()scalbln 宏,引數的類型會決定選取函式的版本。 如需詳細資訊,請參閱 類型泛型數學

根據預設,此函式的全域狀態會限定于應用程式。 若要變更此行為,請參閱 CRT 中的全域狀態。

需求

函式 C 標頭 C++ 標頭
scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl <math.h> <cmath>
scalbnscalbln <tgmath.h>

如需相容性詳細資訊,請參閱相容性

範例

// crt_scalbn.c
// Compile using: cl /W4 crt_scalbn.c
#include <math.h>
#include <stdio.h>

int main( void )
{
   double x = 6.4, y;
   int p = 3;

   y = scalbn( x, p );
   printf( "%2.1f times FLT_RADIX to the power of %d is %2.1f\n", x, p, y );
}

輸出

6.4 times FLT_RADIX to the power of 3 is 51.2

另請參閱

數學和浮點支援
frexp
ldexp
modf, modff, modfl