C Standard Library

C <math.h> - scalbn() Function



The C <math.h> scalbn() function returns the result of multiplying the significand (x) by FLT_RADIX raised to the power of the exponent (n). Mathematically, it can be expressed as:

scalbn(x,n) = x * FLT_RADIXn

On most platforms, FLT_RADIX is 2, which makes this function equivalent to ldexp.

Syntax

double scalbn  (double x, int n);
float scalbnf (float x, int n);
long double scalbnl (long double x, int n);                           

Parameters

x Specify the value representing the significand.
n Specify the value of the exponent.

Return Value

Returns x * FLT_RADIXn.

Example:

The example below shows the usage of scalbn() function.

#include <stdio.h>
#include <math.h>
 
int main (){
  double x, result;
  int n;
  x = 0.9;
  n = 4;

  result = scalbn(x, n);

  printf("Significand: %f\n", x);
  printf("Exponent: %i\n", n);
  printf("Result: %f\n", result);
  return 0;
}

The output of the above code will be:

Significand: 0.900000
Exponent: 4
Result: 14.400000

❮ C <math.h> Library