Liran
Liran

Reputation: 830

The difference between unsigned long and UINT64

What is the difference between unsigned long and UINT64? I think they are the same, but I'm not sure. The definition of UINT64 is :

typedef unsigned __int64    UINT64

(by using StdAfx.h)

Upvotes: 19

Views: 64357

Answers (5)

Sjoerd
Sjoerd

Reputation: 75578

A long is typically 32 bits (but this may vary per architecture) and an uint64 is always 64 bits. A native data type which is sometimes 64 bits long is a long long int.

Upvotes: 1

The C++ standard does not define the sizes of each of the types (besides char), so the size of unsigned long is implementation defined. In most cases I know of, though, unsigned long is an unsigned 32 bit type, while UINT64 (which is an implementation type, not even mentioned in the standard) is a 64 bit unsigned integer in VS.

Upvotes: 5

M. Williams
M. Williams

Reputation: 4985

See http://msdn.microsoft.com/en-us/library/s3f49ktz(VS.90).aspx

You want to see the difference between unsigned long and unsigned __int64.

Upvotes: 3

Stephen Ierodiaconou
Stephen Ierodiaconou

Reputation: 789

The unsigned long type size could change depending on the architecture of the system you are on, while the assumption is that UINT64 is definitely 64 bits wide. Have a look at http://en.wikipedia.org/wiki/C_variable_types_and_declarations#Size

Upvotes: 4

Jason Coco
Jason Coco

Reputation: 78343

UINT64 is specific and declares your intent. You want a type that is an unsigned integer that is exactly 64 bits wide. That this may be equal to an unsigned long on some platforms is coincidence.

Upvotes: 21

Related Questions