Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example of an extended integer type?

Tags:

c

As of C99, C supports implementation-defined extended integer types (6.2.5 p7). Does any implementation actually implement an extended integer type?

I'm aware of gcc's __int128, which is currently treated as a language extension and is not formally listed as an extended integer type in gcc's documentation of implementation-defined behavior (J.3.5). I couldn't find anything mentioned in the documentation for clang or MSVC. Solaris states that there are no extended integer types.

There is some related discussion at What are “extended integer types”?, but the only other candidate mentioned is __int64 in an older version of MSVC, and the comments seem to agree that it's not a formal extended integer type due to that version of MSVC being C90.

like image 669
ov2k Avatar asked Aug 02 '19 19:08

ov2k


People also ask

How do you declare a 64-bit integer 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.

What is a long type C++?

Introduction to C++ long. In C++, long is a data type for a constant or variable which has the capability of storing the variable or constant values with 64-bits storage and is signed integer data type which is used for storing variable or constants with larger values larger than standard integer 32-bit data type.

What is UInt32 in C?

In C#, UInt32 struct is used to represent 32-bit unsigned integers(also termed as uint data type) starting from range 0 to 4,294,967,295.

What is unsigned type in C++?

The unsigned keyword is a data type specifier, that makes a variable only represent non-negative integer numbers (positive numbers and zero). It can be applied only to the char , short , int and long types.


1 Answers

Example of an extended integer type?
Does any implementation actually implement an extended integer type?

Various processors have a 24-bit width for instructions and constant memory.

Compilers supporting such Microchip processors offer (u)int24_t.

int24_t types added to C99 The int24_t and uint24_t types (along with the existing __int24 and __uint24 types) are now available when using the C99 library and when CCI is not active.


Even though some compilers do offer 128-bit integer types, if that type was an extended integer type, the C library would require (u)intmax_t to be at least that width. C11dr 7.20.1.5

C also requires "preprocessor arithmetic done in intmax_t/uintmax_t".

I suspect compilers offering intN (N > 64) do so as a language extension.

I know of no compiler where (u)int128_t exist (as an extended integer type).

like image 156
chux - Reinstate Monica Avatar answered Oct 21 '22 03:10

chux - Reinstate Monica