Solved

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

Posted on 2008-06-22
4
3,275 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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sistemu earned 150 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 150 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
MVC DDL Json Not Binding to Model 2 28
location of a form 2 25
FInd Image Control Gridview 3 23
I need help adding validation to my MVC.Net view 6 11
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

808 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