// complex_log10.cpp // compile with: /EHsc #include <vector> #include <complex> #include <iostream> int main() { using namespace std; double pi = 3.14159265359; complex <double> c1 ( 3.0 , 4.0 ); cout << "Complex number c1 = " << c1 << endl; // Values of log10 of a ...
(1)(C99 起) doublelog10(doublearg); (2) longdoublelog10l(longdoublearg); (3)(C99 起) 定义于头文件<tgmath.h> #define log10( arg ) (4)(C99 起) 1-3)计算arg的常用(底10)对数。 4)泛型宏:若arg拥有longdouble类型,则调用log10l。否则,若arg拥有整数类型或double类型,则调用log10。否则调...
printf( "log10( %.2f ) = %f\n", x, y ); } Output code log( 9000.00 ) = 9.104980 log10( 9000.00 ) = 3.954243 To generate logarithms for other bases, use the mathematical relation: log base b of a == natural log (a) / natural log (b). code // logbase.cpp #include <math...
From cppreference.com <c |numeric |math Numerics Common mathematical functions Floating-point environment(C99) Pseudo-random number generation Complex number arithmetic(C99) Type-generic math(C99) Types div_tldiv_tlldiv_timaxdiv_t
// logbase.cpp#include<math.h>#include<stdio.h>doublelogbase(doublea,doublebase){returnlog(a) /log(base); }intmain(){doublex =65536;doubleresult; result = logbase(x,2);printf("Log base 2 of %lf is %lf\n", x, result); } ...
// logbase.cpp#include<math.h>#include<stdio.h>doublelogbase(doublea,doublebase){returnlog(a) /log(base); }intmain(){doublex =65536;doubleresult; result = logbase(x,2);printf("Log base 2 of %lf is %lf\n", x, result); } ...
// valarray_log10.cpp // compile with: /EHsc #include <valarray> #include <iostream> #include <iomanip> int main( ) { using namespace std; int i; valarray<double> va1 ( 11 ); for ( i = 0 ; i < 11 ; i++ ) va1 [ i ] = 10 * i; valarray<double> va2 ( 9 ); cout...
// explog10.cpp // compile with: /EHsc #include <iostream> // for i/o functions #include <valarray> // for valarray #include <math.h> // for exp(), log(), and log10() using namespace std; #define ARRAY_SIZE 3 // array size typedef valarray<double> DB_VARRAY; int main() ...
Return the base 10 logarithm of different numbers: cout<<log10(120.0f);cout<<log10(10.0f);cout<<log10(3.1623);cout<<log10(1.0);cout<<log10(0.0f);cout<<log10(-1.0f); Try it Yourself » Definition and Usage Thelog10()function returns the base 10 logarithm of a number. ...
std::log10(std::valarray) C++ Numerics library std::valarray Defined in header<valarray> template<classT> valarray<T>log10(constvalarray<T>&va); For each element invacomputes common (base 10) logarithm of the value of the element.