The frexp() function breaks the floating point number x into its binary significand i., e., floating point with an absolute value between [0.5, 1.0) and an integral exponent for 2.
x = significand * (2^exponent).
It used to :
1. It is used to find significand which is always between 0.5 and 1.0 2. It is used to find exponent which is power of 2.
double frexp (double x); float frexp (float x); long double frexp (long double x);
- The frexp() function takes a single argument.
- The frexp() function returns the binary significand whose absolute value lies in the interval [0.5, 1).
- If x is zero, both significand and exponent are zero.
Error and Exception:
- It is mandatory to give both the arguments otherwise it will give error no matching function for call to ‘frexp()’.
- If we pass a string as an argument we will get an error no matching function for call to ‘frexp(const char [n]).
- If x=0 then significand is zero and exponent is zero
- x >= 1 then significand is positive number and exponent is positive number
- x <= -1 then significand is negative number and exponent is positive number
- -1 < x < 0 then significand is negative number and exponent is negative number
- 0 < x < 1 then significand is positive number and exponent is negative number
# CODE 1
5.35 = 0.66875 * 2^3
# CODE 2
5 = 0.625 * 2^3
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.
- Difference between cout and puts() in C++ with Examples
- Difference between forward list and list in C++
- Short-Circuiting in C++ and Linux
- Different types of range-based for loop iterators in 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++
- Reversed Range-based for loop in C++ with Examples
- 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
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.