Are These All The Integer Types In C


 
Thread Tools Search this Thread
Top Forums Programming Are These All The Integer Types In C
# 1  
Old 09-20-2017
Are These All The Integer Types In C

Hello and Good day, I am currently studying C and I just finished learning about variables mainly those of integer type.

I am wondering if the list below are all there is to integer variables and there are still more that i have to learn.

Here are the list:
Char
Short
int
long
long long

float
double
long double.
# 2  
Old 09-20-2017
The only parts you didn't mention are signed vs unsigned, pointers, and bitfields. Pointers on most modern systems are all the same size, related to the system's address size, i.e. 32-bit on 32 bit systems, 64-bit on 64.

Note that "long long" and "long double" are nonstandard types, unavailable on many systems. "long long" particularly is no longer needed to get a 64-bit type, 'long' has become natively 64-bit on modern 64-bit computers (except on Windows for some reason).

Also, the exact number of bits in 'char', 'short', 'int', and 'long' are not rigidly defined by the language, they're a fact of the processor you use it with, though even there they're sometimes interpreted differently from publisher to publisher. There was a compiler for a strange Cray supercomputer which had no types smaller than 64 bits!

Bitfields are a rarely-used feature which can make an integer of an arbitrary number of bits (probably up to the system word size.) int y:4; Voila, a 4-bit integer which can represent values from -8 to +7. This feature is mostly avoided as it's slow and wasteful of space. I've only seen it used exactly once -- to make ersatz 32-bit integers for that strange Cray supercomputer.

Last edited by Corona688; 09-20-2017 at 01:04 PM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-22-2017
Hi Corona688,
The signed, unsigned, and "unadorned" long long int types (i.e., signed long long int, unsigned long long int, and long long int) weren't available in K&R C nor in the first version of the ISO C Standard, but have been ISO C standard types since the 2nd version of the standard (AKA C99).

C99 also added the header <inttypes.h> which requires for a (possibly larger than long long) intmax_t. It also requires the types intN_t and uintN_t where N is 8, 16, 32, and 64 to hold signed and unsigned, respectively, integers of exactly 8, 16, 32, and 64 bits, respectively. It requires that intmax_t be a signed integer type of at least 64 bits and that uintmax_t be an unsigned integer type of at least 64 bits. And, it allows additional N values for any other lengths of integer types supported by your compiler.

I don't know of many compilers that support other lengths, but I have seem plans to develop a compiler that would at least support int96_t, uint96_t, int128_t, and uint128_t on 64-bit architecture hardware.
This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 09-25-2017
Thanks guys for your contributions.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cp -r except certain file types

the following excludes certain directories successfully cp -r probe/!(dir) /destination I want to exclude certain file types and tried unsuccessfully cp -r probe/!(*.avi) /destination (2 Replies)
Discussion started by: tmf
2 Replies

2. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

3. What is on Your Mind?

What Types of Food Do You Like The Most?

On another simple topic, multiple choice answers OK ( you can pick more than one or suggest others - we will add your suggestions to the poll ). What Types of Food Do You Like The Most? (27 Replies)
Discussion started by: Neo
27 Replies

4. Programming

enumeration types in C

If I want to declare an array of structures in C and have the number of items in that array to correspond to the items of an enumeration, is there a way to access the maximum value in the enumeration when declaring the array? For instance: typedef struct { various fields.... } ... (3 Replies)
Discussion started by: cleopard
3 Replies

5. UNIX for Dummies Questions & Answers

Un-compression types...

Hi Folks, As I am familiar wih both types compresion forms: gun-zip and .rpm. My questions is how do I uncompress gunz.zip type? As the .rpm I can double click and it will extract...Can someone shed some light on this and thank you... M (2 Replies)
Discussion started by: Mombo_Z
2 Replies

6. UNIX for Dummies Questions & Answers

mime types

Hi, I am trying to launch an ogg movie from a pdf file which has been produced with pdflatex and \movie {\centerline{\includegraphics {grafiques_xerrades/un_manolo_amb_camera.pdf}}} {hlims_xerrades/XocCumuls.ogg} The switch "externalviewer" makes kpdf launch the default... (5 Replies)
Discussion started by: pau
5 Replies

7. UNIX for Dummies Questions & Answers

Two types of pipes?

What is the difference between: cd /tmp tar -cf - *.txt |gzip > tmp_txt.tar.gz and cd /tmp mknod pipe p gzip < pipe > /tmp/tmp_txt1.tar.gz & tar -cf pipe *.txt Apart from the fact that we have to create the pipe file manually, is there any difference in the performance of the two?... (5 Replies)
Discussion started by: blowtorch
5 Replies

8. Filesystems, Disks and Memory

associated file types

I have a file of type .for extension .In a guui based unix environment like solaris if I double click on that file a specific program designed by me has to run which takes this file as the parameter and exceutes the program. Can anyone help me? (8 Replies)
Discussion started by: nhk_srd
8 Replies

9. UNIX for Dummies Questions & Answers

backup types

can anyone explain me difference between tar and ufsdump commands.............and also i wd like to know the difference between incremental and differential backup......... thx in advance (1 Reply)
Discussion started by: girish_shukla
1 Replies
Login or Register to Ask a Question