advertisement
advertisement
Welcome, Guest!     DevX Log In | Premier Club Log In/Registration
   Include Code   Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
Tip of the Day
Rate this item | 0 users have rated this item.
Expertise: Intermediate
Language: C++
January 30, 2006
Avoiding Ambiguity in Math.h functions While Porting from 32-bit to 64-bit
One of the most common errors while porting from 32-bit Code to a 64-bit code is in the use of Math.h library functions.

Suppose you use a call to the pow function and get an error such as "Ambiguous call to a overloaded member function" in the 64-bit compiler. The reason is that a few more overloaded functions have been added to the math.h making it ambiguous for the compiler to understand which function to call. For example, pow now has seven overloads:


long double pow(long double,int)
long double pow(long double,long double)
float pow(float,int)
float pow(float,float)
double pow(int,int)
double pow(double,int)
double pow(double,double)
The straightforward solution to this problem is to call the methods with the explicit parameter typecast. So the call now looks like:

pow((float)11,(float)2.0)
or:

pow((double)11,(double)2.0)
... and so on and so forth.

Modifying your existing 32-bit code for explicit parameters works with both 32-bit and 64-bit code and helps make porting a bit less painful.

C.V. Ram
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
advertisement
Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

JupiterWeb networks:

internet.comearthweb.comDevx.comGraphics.com

Search JupiterWeb:

Jupitermedia Corporation has three divisions:
Jupiterimages, JupiterWeb and JupiterResearch


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | Shopping | E-mail Offers