quick question about log

This is a discussion on quick question about log within the C++ Programming forums, part of the General Programming Boards category; hi i'm working on an assignment and i'm suppose to take the log of a number , on the assignment ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    5

    quick question about log

    hi
    i'm working on an assignment and i'm suppose to take the log of a number , on the assignment sheet it looks like this:

    log( totalAmount) - 1

    my question is how do i write log in c++ ? like i know to get a number to the second power x it will be something like (pow(number), x)

    so anyone who can help is welcome

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    log in c is written
    Code:
    #include <math.h>
    
    a = log(b);
    which gives the natural log of b. If you need to convert it to soem other base then simply divide the natural log of b by the natural log of the base you want and it gives you the log of b in that base.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21