1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help! Error in MSVC++ .NET version

  1. Feb 3, 2005 #1

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Is anyone here using Visual C++ .NET?
    I have a line of code that works fine in MSVC++ v6, but I am getting an error in MSVC++ .NET. :mad: :cry: :cry:

    Here's the line:

    expo = (log(num))/(log(10));

    and the error message I get:

    error C2668: 'log': ambiguous call to overloaded function

    expo is a type int variable. so is num.
    I am using the cmath header:
    #include <cmath>

    Thanks for any help!
     
  2. jcsd
  3. Feb 3, 2005 #2

    dduardo

    User Avatar
    Staff Emeritus

    It should be:

    expo = log((double)num)/log(10.) ;

    And you'll get a warning if expo is not a double. num can stay int since i've typecasted it.

    The log function in cmath is defined as:

    double log( double )
    long double log( long double )
    float log( float )
     
    Last edited: Feb 3, 2005
  4. Feb 3, 2005 #3

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Thanks, dduardo. I was breaking out in a mild panic!!
    Is what you did there the same as using static_cast<double>?
     
  5. Feb 3, 2005 #4

    dduardo

    User Avatar
    Staff Emeritus

    Yeah, you can write it either way. The parentheses is just a shorthand.
     
    Last edited: Feb 3, 2005
  6. Feb 3, 2005 #5

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    oh, ok... thanks!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Help! Error in MSVC++ .NET version
  1. Net's state (Replies: 2)

  2. Net view (Replies: 9)

Loading...