Home » C programs » math.h header file functions

frexp() function of math.h in C

In this article, we are going to learn about the use frexp() function of math.h header file and then try to understand it with the help of an example.
Submitted by Manu Jemini, on March 30, 2018

This is an advance function used to get the absolute value of a floating point value in the form of mantissa which lies in the interval of [0.5, 1).

The Function takes two parameters, first is the number and second is the address of the integer.


    X = 16.4324

    Then the significant will be 0.513512

The Formula to find the mantissa is x = mantissa * 2 ^ exponent.

If the value of 'x' is zero, the function will return 0 and store it in the int.

The function also asks for the address of an integer which will get the normalizing fraction. This function is a part of math.h library and we must include it in the program.


math.h - frexp() function Example in C

#include <stdio.h>
#include <math.h>

int main()
	float a,c;
	// Defining variables
	int b;

	// Assigning value for getting frexp value
	a = 16.4324;

	// Calculating floating-point value into a fraction and an exponent
	c = frexp(a, &b);

	// Displaying the result for the user
	printf("The calculated value is: %f \n\n", c);

	return 0;


math.h - frexp()  in c language



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.