Why is it ambiguous to call overloaded ambig(long) and ambig(unsigned long) with an integer literal?

You’re passing an int to this overloaded function. Although human intuition says that ambig(signed long) ought to be preferred because your input is a negative integer (which cannot be represented as such by an unsigned long), the two conversions are in fact equivalent in “precedence” in C++. That is, the conversion int → unsigned long … Read more

How to include the stdafx.h from the root directory?

Visual C++ allows you to define several ways of setting up precompiled header files. The most common is to enable it for ALL source files at the project configuration level, Under Configuration Properties/C++/Precompiled Headers, setting “Precompiled Header”, select “Use”. The same location, setting “Precompiled Header File”, is usually “stdafx.h”. All files will get this setting … Read more

__int64 on a 32-Bit machine?

Same way 32-bit arithmetic worked on 16-bit systems. In this case, it uses 2 32-bit memory addresses to form a 64-bit number together. Addition/substraction is easy, you do it by parts, the only gotcha is taking the carry-over from the lower part to the higher part. For multiplication/division, it’s harder (ie more instructions). It’s obviously … Read more

tech