您的位置:首页 > 编程语言 > C语言/C++

Summary of learning data type

2016-09-29 19:47 375 查看

Summary of learning data type

16340286

School of Data and Computer Science

Contents

Summary of learning data type
Brief Introdution

Storage size
Operator sizeof

Value range

Integer constants3
Positional Notation

References

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

TypeSize
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

TypeValue rangeOperation
intinteger in INT_MIN~INT_MAX+−∗/...
floata 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=∑i=1ndiRi−1

n is the number of digits in the number

d is the digit in the ith 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

References

https://en.wikipedia.org/wiki/Data_type#cite_note-1
http://www.tutorialspoint.com/cprogramming/c_data_types.htm
http://aboutc.weebly.com/integer-constants.html
http://ss.sysu.edu.cn/~pml/se121/2011fall/slides/02-NumberSystem.pdf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐