The ldexp() function takes two arguments a and b and returns the product of a and 2 raised to the power of b i.e., a * (2b).
double ldexp (double a, double b); float ldexp (float a, float b); long double ldexp (long double a, long double b);
- The ldexp() function takes two arguments a, b and computes a * (2b).
- Here a and b can be anything which is valid.
- The ldexp() function returns a * (2^b) if we pass a and b as the arguments.
- It is mandatory to give both the arguments otherwise it will give error no matching function for call to ‘ldexp()’.
- If we pass string as argument we will get error no matching function for call to ‘ldexp(const char [n], const char [n]) .
- If we pass std::numeric_limits::max() as both the arguments we will get inf(infinity) as output.
Errors and exceptions associated with this function:
Input : ldexp(5.35, 4) Output : 85.6
Input : ldexp(25, 5) Output : 800
# CODE 1
# CODE 2
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- ldexp() function in C/C++
- Learn C++ Programming Step by Step - A 20 Day Curriculum!
- Why do we need reference variables if we have pointers
- Similarities and Difference between Java and C++
- Macros and its types in C/C++
- How to find index of a given element in a Vector in C++
- Introduction to Complex Objects and Composition
- NULL undeclared error in C/C++ and how to resolve it
- std::remove_const in C++ with Examples
- Finding Median of unsorted Array in linear time using C++ STL
- Average of Cubes of first N natural numbers
- Top 10 Programming Languages for Blockchain Development
- Memory Allocation in Static Data Members in C++
- Exception header in C++ with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.