Thread: C math log() function misbehaves...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    Excel does have two log function, the LOG() function would, in C++ style be defined as:
    Code:
    double log(double x, double base = 10);
    The log10() is shorthand for Log(x, 10).

    --
    Mats
    Think you didn't get me well.. Do you mind testing both Excel LOG(7.9454E-18) & LOG10(7.9454E-18) and see if you get different results? That's where my problem is, i get same results...

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    Think you didn't get me well.. Do you mind testing both Excel LOG(7.9454E-18) & LOG10(7.9454E-18) and see if you get different results? That's where my problem is, i get same results...
    If I do, I suspect that means that I should send a bug report to Microsoft (unless the difference is in the 11th decimal point or so).

    What I was trying to say is that log(x) == log10(x) in excel, but it also allows two parameters to log, e.g. log(8, 2), which would give you log2(8) [which is three]. So if you give only one parameter, you get log10, if you give two parameters, log(x, y) you get logy(x).

    Does that make more sense?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    If I do, I suspect that means that I should send a bug report to Microsoft (unless the difference is in the 11th decimal point or so).

    What I was trying to say is that log(x) == log10(x) in excel, but it also allows two parameters to log, e.g. log(8, 2), which would give you log2(8) [which is three]. So if you give only one parameter, you get log10, if you give two parameters, log(x, y) you get logy(x).

    Does that make more sense?

    --
    Mats
    Oh! eish... it's friday so forgive me..

    Thnx

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    If I do, I suspect that means that I should send a bug report to Microsoft (unless the difference is in the 11th decimal point or so).

    What I was trying to say is that log(x) == log10(x) in excel, but it also allows two parameters to log, e.g. log(8, 2), which would give you log2(8) [which is three]. So if you give only one parameter, you get log10, if you give two parameters, log(x, y) you get logy(x).

    Does that make more sense?

    --
    Mats
    Interesting this

    The Log base 10....

    In C/C++: log10(x)... Excel: LOG10(x) == LOG(x) == LOG(x, 10),... Sci Calc: log

    Log base e....

    In C/C++: log(x) ... Excel: LN(x)... Sci Calc: ln

    Can be confusing if using all to test a function...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM