Summary of learning data type
16340286
School of Data and Computer Science
Contents
Brief Introdution
In computer science and computer programming, a data type or simply type is a classification identifying one of various types of data, such as real, integer or Boolean, that determines the possible values for that type, the operations that can be done on values of that type, the meaning of the data, and the way values of that type can be stored.1
A set of values ,along with a set of operations on those values.
Storage size
Type | Size | |||
---|---|---|---|---|
char memory cell | ▇▇▇▇ | |||
short memory cell | ▇▇▇▇ | ▇▇▇▇ | ||
int memory cell | ▇▇▇▇ | ▇▇▇▇ | ▇▇▇▇ | ▇▇▇▇ |
long memory cell | ▇▇▇▇ | ▇▇▇▇ | ▇▇▇▇ | ▇▇▇▇ |
Operator sizeof
C has a unary operator named size of that yields the size on your machine in bytes of its single operand.The operand can be a variable name,or it can be the name of a data type enclosed in parentheses.2
#include <stdio.h>
#include <limits.h>
int main()
{
printf("Storage size for char : %d \n", sizeof(char));
printf("Storage size for int : %d \n", sizeof(int));
return 0;
}
Display:
Storage size for char : 1
Storage size for int : 4
Value range
Type | Value range | Operation |
---|---|---|
int | integer in INT_MIN~INT_MAX |
+−∗/...
|
float | a set of all real numbers the computer can state |
+−∗/
|
char | -128~127 |
+−∗/
% |
Integer constants3
- Any whole number value is an integer.
- An integer constant refers to a sequence of digits without a decimal point.
- An integer preceded by a unary minus may be considered to represent a negative constant
There are three types of integer constants namely
a) Decimal integer constant
b) Octal integer constant
c) Hexadecimal integer constant
Positional Notation
The formula4 is:
n is the number of digits in the number
d is the digit in the i th position in the number
R is the baseof the number
Example:
03172=3*83+1*82+7*81+2*80=1658
0x67A=6*162+7*161+10*160=1658