English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and Example of C Library Function ldexp()

C Standard Library - <math.h>

C Library Function double ldexp(double x, int exponent) returns x multiplied by 2 of exponent power

Declaration

Below is the declaration of the ldexp() function.

double ldexp(double x, int exponent)

parameter

  • x  -- represents the floating-point value of the significant digits.

  • exponent  -- to the power of the exponent.

Return Value

This function returns the value of x * 2 exp.

Online Example

The following example demonstrates the usage of the ldexp() function.

#include <stdio.h>
#include <math.h>
int main ()
{
   double x, ret;
   int n;
   x = 1.65;
   n = 5;
   ret = ldexp(x, n);
   printf("%f * 2^%d = %f\n", x, n, ret);
   
   return(0);
}

Let's compile and run the above program, which will produce the following result:

1.650000 * 2^5 = 52.800000

C Standard Library - <math.h>