added range of values (#33656)
* added range of values * fix: formatted table with markdownpull/28705/head^2
parent
6822234614
commit
18908b40c4
|
@ -17,6 +17,7 @@ Since C is not interpreted language, it is not allowed to declare variables dyna
|
|||
|
||||
#### Characters: `char`
|
||||
`char` holds characters- things like letters, punctuation, and spaces. In a computer, characters are stored as numbers, so `char` holds integer values that represent characters. The actual translation is described by the ASCII standard. <a href='http://www.asciitable.com/' target='_blank' rel='nofollow'>Here's</a> a handy table for looking up that.
|
||||
The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
|
||||
|
||||
The actual size, like all other data types in C, depends on the hardware you're working on. By minimum, it is at least 8 bits, so you will have at least 0 to 127. Alternatively, you can use `signed char` to get at least -128 to 127.
|
||||
|
||||
|
@ -102,8 +103,22 @@ There are various functions in C which do not accept any parameter. A function w
|
|||
#### 3. Pointers to void
|
||||
A pointer of type void * represents the address of an object, but not its type. For example, a memory allocation function ```void *malloc( size_t size);``` returns a pointer to void which can be casted to any data type.
|
||||
|
||||
| Data Type | Memory (bytes) | Range | Format Specifier |
|
||||
|-----------| :--------------: | :-----: | :----------------: |
|
||||
| short int | 2 | -32,768 to 32,767 | %hd |
|
||||
| unsigned short int | 2 | 0 to 65,535 | %hu |
|
||||
| unsigned int | 4 | 0 to 4,294,967,295 | %u |
|
||||
| int | 4 | -2,147,483,648 to 2,147,483,647 | %d |
|
||||
| long int | 4 | -2,147,483,648 to 2,147,483,647 | %ld |
|
||||
| unsigned long int | 4 | 0 to 4,294,967,295 | %lu |
|
||||
| long long int | 8 | -(2^63) to (2^63)-1 | %lld |
|
||||
| unsigned long long int | 8 | 0 to 18,446,744,073,709,551,615 | %llu |
|
||||
| signed char | 1 | -128 to 127 | %c |
|
||||
| unsigned char | 1 | 0 to 255 | %c |
|
||||
| float | 4 | | %f |
|
||||
| double | 8 | | %lf |
|
||||
| long double | 12 | | %Lf |
|
||||
|
||||
# Before you go on...
|
||||
## A review
|
||||
* The actual abilities of C data types depend on the hardware. As a result, minimum sizes are defined for the data types.
|
||||
* Floating point numbers will allow you to have decimals, while integer numbers won't.
|
||||
|
|
Loading…
Reference in New Issue