This shows you the differences between two versions of the page.
c:math.h:frexp [2013/01/22 22:02] |
c:math.h:frexp [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ===== frexp ===== | ||
+ | <code c> | ||
+ | double frexp(double); | ||
+ | </code> | ||
+ | Mantissa m. in *n is the exponent. | ||
+ | |||
+ | ===== C Sourcecode Example ===== | ||
+ | compile in linux with: gcc frexp.c -o frexp **-lm** -Wall | ||
+ | <code c> | ||
+ | #include <stdio.h> /* including standard library */ | ||
+ | //#include <windows.h> /* uncomment this for Windows */ | ||
+ | |||
+ | #include <math.h> /* including math library */ | ||
+ | |||
+ | int main ( void ) | ||
+ | { | ||
+ | double x; | ||
+ | int n; | ||
+ | |||
+ | x = 42.0; | ||
+ | printf ("%lf * 2^%d = %f\n", frexp (x , &n), n, x); | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | </code> | ||
+ | ==== output ==== | ||
+ | output: | ||
+ | user@host:~$ ./frexp | ||
+ | 0.656250 * 2^0 = 42.000000 | ||