log10f()
in C calculates the base-10
logarithm of a floating point value. log10f()
is defined in the math.h
header file and the function declaration is as follows:
float log10f(float arg);
arg
: floating point value
Input | Output | Error Raised |
> 0 and no error occurs | base-10 logarithm | - |
1 | +0 | - |
+∞ | +∞ | - |
NaN | NaN | - |
< 0 | NaN | Domain error |
±0 | -∞ | Pole error |
#include <math.h>#include <stdio.h>int main(void){printf("log10f(100) = %f\n", log10f(100));printf("log10f(0.0001) = %f\n", log10f(0.0001));/* special cases */printf("log10f(1) = %f\n", log10f(1));printf("log10f(0) = %f\n", log10f(0));printf("log10f(0) = %f\n", log10f(-10));printf("log10f(+inf) = %f\n", log10f(INFINITY));printf("log10f(nan) = %f\n", log10f(NAN));return 0;}
You need to include the
math
library using-lm
flag when you compile any program that useslog10f()
.
First, we import the math.h
header file from the C standard library. The program then prints the output of log10f()
on possible example values. You can confirm the output using the table above.
Free Resources