====== frexp() ====== frexp ist definiert in der ''[[start|math]]'', die in C über ''math.h'', bzw. in C++ über ''cmath'' eingebunden wird. ===== Funktion ===== frex teilt eine Fließkommazahl in Faktor und Potenz zur Basis zwei auf. (''floatingPoint = factor * 2exp'') ===== Signatur ===== #include double frexp( double floatingPoint, int * exp ); float frexp( float floatingPoint, int * exp ); // nur C++ long double frexp( long double floatingPoint, int * exp ); // nur C++ **factor**: \\ **exp**: Ausgabeparameter: Adresse für ein Integer, um den Exponent zur Basis zwei abzulegen **Return value**: Wert, mit dem die Potenz von exp zur Basis 2 multipliziert wird, um dem Parameter floatingPoint zu entsprechen ===== Fehlerquellen ===== exp wird hier ausschließlich als Ausgabeparameter verwendet. ===== Beispiel ===== #include // für EXIT_SUCCESS #include // für log10 #include // für printf() int main( void ) { double factor; int exp; double floatingPoint = 12; factor = ldexp( floatingPoint, &exp ); printf( "%f * 2^%f entspricht %f\n", factor, exp, floatingPoint ); return EXIT_SUCCESS; } Ausgabe: 3.000000 * 2^2.000000 entspricht 12.000000 ===== Hinweis ===== frexp lässt sich mit [[c:lib:math:ldexp()]] umkehren. Zu beachten ist, dass der Faktor entsprechend einer Fließkommazahl immer zwischen größer -1.0 und kleiner 1.0 liegt, aber nie -1.0 oder +1.0 erreicht. ===== siehe auch ===== [[c:lib:math:start|math]]: [[c:lib:math:ldexp()]], [[c:lib:math:pow()]], [[c:lib:math:log()]] \\