Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

<math.h> error in Microsoft Visual C++

Posted on 2008-06-22
4
Medium Priority
?
3,380 Views
Last Modified: 2013-11-26
I've created a header file which contains lines like this :

Value = 1*pow(10,13) + 3 * pow(10.0,4) , where Value is an unsigned long long.

The header file was working perfectly on Borland C++ Builder 6. I've tried to run it using Microsoft Visual Studio 2008,(Visual C++) and i get errors like this:

c:\my documents\visual studio 2008\projects\chrysaor\chrysaor\File2.h(168) : error C2668: 'pow' : ambiguous call to overloaded function
        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(575): could be 'long double pow(long double,int)'
        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(527): or       'float pow(float,int)'
        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(489): or       'double pow(double,int)'
        while trying to match the argument list '(int, int)'

Why this happens and how do I fix it?

Thanks a lot.
0
Comment
Question by:Chrysaor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sistemu earned 600 total points
ID: 21841015
Hi
Try using:
Value = 1*pow(10.0,13) + 3 * pow(10.0,4)

OR:
Value = 1*pow((double)10,13) + 3 * pow((double)10.0,4)

Function pow has 3 overloads:
~ long double pow(long double,int)
~ float pow(float,int)
~ double pow(double,int)
but either one corresponds to the way you call them.
0
 
LVL 11

Expert Comment

by:cup
ID: 21841625
Since your result is a long long, just to be safe, make the 1 and 3 1LL and 3LL respectively.
0
 
LVL 11

Expert Comment

by:cup
ID: 21841696
Since your result is a long long, just to be safe, make the 1 and 3 1LL and 3LL respectively.
0
 
LVL 7

Assisted Solution

by:johnnash1180
johnnash1180 earned 600 total points
ID: 21845157
Hmmmm..
The following may help.

long double Value = 1LL*pow(10.0f,13) + 3LL * pow(10.0f,4);

The complete documentation of pow function at the following URL:
http://msdn.microsoft.com/en-us/library/dt5dakze(VS.71).aspx

Nash J
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question