Results 1 to 5 of 5

Thread: Use of the log10() in C++

  1. #1
    Join Date
    Dec 2009
    Posts
    28

    Use of the log10() in C++

    I am working in the ABC company as software developer. We can use the C++ language for developing the software. Hence, I can not know about the log10() function of the C++ language. So, I would like to know about the log10() function of the C++ language. I also would like to know about what is the use of the log10() function of the C++ language. Can anyone has the solution for me then reply!!!!

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Use of the log10() in C++

    The lod10() function of the C++ language can be used to calculate the common logarithm of an elements of the valarray. The log10() function can returns an object of the valarray that can containing the common logarithm that is base-10 logarithm of all an elements of y. The log10() function can overloads the cmath's log10 function. The following can be the general form of the log10() function of the C++ language :
    Code:
    template<class S> valarray<S> log10 (const valarray<S>& y);

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Use of the log10() in C++

    I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the log10() function in the C++ programming as follows :
    Code:
    #include <iostream>
    #include <cmath>
    #include <vlarray>
    using namespace std;
    int main ()
    {
      double vl[] = {1.0, 10.0, 100.0, 200.0};
      vlarray<double> foo (vl,4);
      vlarray<double> br = log10 (foo);
      cout << "foo: ";
      for (size_t j=0; j<foo.size(); ++j)
    	  cout << foo[j] << ' ';
      cout << endl;
      cout << "br: ";
      for (size_t j=0; j<br.size(); ++j)
    	  cout << br[j] << ' ';
      cout << endl;
      return 0;
    }
    Output:
    Code:
    foo: 1 10 100 200
    br: 0 1 2 2.30103

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of the log10() in C++

    The log10() function of the C++ language can returns the value of an object of the valarray with the common logarithmic of an elements of the y. The following can be the parameters of the log10() function in the C++ language :
    1. x : This parameter of the log10() function of the valarray containing an elements of a type for that the unary function log10 can be defined.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Use of the log10() in C++

    The log10() function of the C++ language can returns the base 10 logarithm for num. There can be a domain error if the num can be a negative value and a range of an error if num can be zero. The log10() function of the C++ language can be comes under the valarray header files. See the following example :
    Code:
    #include <iostream>
    #include <cmath>
    using namespace std;
    int main ()
    {
      double prm, rslt;
      prm = 1000.0;
      rslt = log10(prm);
      cout << "log10(" << prm << ") = " << rslt << "\n";
      return 0;
    }
    Output:
    log10(1000) = 3
    Last edited by Modifier; 10-03-2010 at 04:36 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,827,657.39829 seconds with 15 queries