C Standard Library

C <math.h> - scalbln() Function



The C <math.h> scalbln() 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:

scalbln(x,n) = x * FLT_RADIXn

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

scalbn() is similar to this function, except scalbn() takes int as second argument.

Syntax

double scalbln  (double x, long int n);
float scalblnf (float x, long int n);
long double scalblnl (long double x, long 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 scalbln() function.

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

  result = scalbn(x, n);

  printf("Significand: %f\n", x);
  printf("Exponent: %li\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