![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
frexp() in C++
The function frexp() is used to break the floating point number into its binary significand and integral exponent for 2. It returns the binary significand and its range is (0.5, 1). If we pass value zero, its significand and exponent value will be zero.
Here is the mathematical expression of frexp(),
x = significand * (2^exponent)
Here is the syntax of frexp() in C++ language,
float frexp(float variable_name, int* exponent);
Here,
variable_name − Any name of variable which has floating number to be decomposed into binary significant.
exponent − It is a pointer to int where value of exponent is stored.
Here is an example of frexp() in C++ language,
Example
#include <iostream> #include<math.h> using namespace std; int main() { double a = 4; int* b; cout<<"Value of a : "<< a <<'\n'; double s = frexp(a, b); std::cout << a << " = " << s << " * " << "2^" << *b; return 0; }
Output
Here is the output:
Value of a : 4 4 = 0.5 * 2^3
Advertisements