Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between int64 and int64_t in C++?

Tags:

I am new to c++ and coding in general. so this question might be noobish. what is the difference in using type int64 or int64_t. I saw that one of the software devs modified their source on github and all of the int64 to int64_t.

like image 789
awaisharoon Avatar asked Oct 27 '14 06:10

awaisharoon


People also ask

What is __ Int64 in C?

Microsoft C/C++ features support for sized integer types. You can declare 8-, 16-, 32-, or 64-bit integer variables by using the __intN type specifier, where N is 8, 16, 32, or 64.

Is int64_t same as long?

In a 64-bit compile, int64_t is long int , not a long long int (obviously).

Should I use long long or int64_t?

If long long is present, it must have at least 64 bits, so casting from (u)int64_t to (unsigned) long long is value-preserving. If you need a type with exactly 64 bits, use (u)int64_t , if you need at least 64 bits, (unsigned) long long is perfectly fine, as would be (u)int_least64_t .

What is the difference between UInt64 and Int64?

Int64 is used to represents 64-bit signed integers . UInt64 is used to represent 64-bit unsigned integers.


1 Answers

int64_t is a Standard C++ type for a signed integer of exactly 64 bits. int64 is not a standard type.

The first C++ standard didn't have fixed-width types. Before int64_t was added to Standard C++, the different compilers all implemented a 64-bit type but they used their own names for it (e.g. long long, __int64, etc.)

A likely series of events is that this project originally would typedef int64 to the 64-bit type for each compiler it was supported on. But once compilers all started to support Standard C++ better, or once the person who wrote the code found out about int64_t, the code was switched over to use the standard name.

like image 80
M.M Avatar answered Sep 28 '22 03:09

M.M