log10 ist definiert in der math
, die in C über math.h
, bzw. in C++ über cmath
eingebunden wird.
log10() berechnet den Logarithmus zur Basis 10.
#include <math.h> double log10( double x ); float log10( float x ); // nur C++ long double log10( long double x ); // nur C++
x: Wert, dessen Logarithmus zur Basis 10 bestimmt werden soll
Return value: Wert, der als Potenz zu 10 x ergibt
Wird als Parameter ein negativer Wert genommen, so wird die globale Variable errno auf EDOM gesetzt. Ist x
gleich Null, so wird -HUGE_VAL zurückgegeben und errno auf ERANGE gesetzt.
#include <stdlib.h> // für EXIT_SUCCESS #include <math.h> // für log10 #include <stdio.h> // für printf() int main( void ) { double value = 10000; double power; power = log10( value ); printf( "10^%f entspricht %f\n", power, value ); return EXIT_SUCCESS; }
Ausgabe:
10^4.000000 entspricht 10000.000000