BP-2-1 Fundamental Data Type

Chapter 02 Description of Simple Data

1. Data Type

Data type is composed of value set and operation set and can be divided into primitive data type and compound data type.

In terms of the requirement of declaration on data type, programming language can be classified as:

  • Statically typed language call for declaration on type of each data and usually executed by compiling.
  • Dynamically typed language doesn’t need to claim data type and usually executed by interpreting.

2. Fundamental Data Type

Fundamental data type is predefined by the language and is also called standard type or built-in type.

Fundamental data type is mostly arithmetic type.

2.1 Integral Type
1. integer type
  • int
  • short int or short, ranging from -32768 to 32767, occupying 2 byte.
  • long int or long

Range(short int) <= Range(int) <= Range(long int)

Unsigned integer is twice the range of usual integer type.

在这里插入图片描述

2. character type
  • char

Character is stored in computer as ASCII, which means American Standard Code for Information Interchange.

在这里插入图片描述

3. boolean type
  • bool

Boolean type has only two value: true or false, while true is often stored as 1 and false is often stored as 0.

在这里插入图片描述

2.2 Real Type

Real type is also called float point type in C++.

  • float
  • double
  • long double

Range(float) < Range(double) <= Range(long double)

在这里插入图片描述

2.3 Void Type
  • void

Void type is used to describe the type of the return value of a function that actually doesn’t return a value.

在这里插入图片描述

2.4 Some Operations
  • We can use function sizeof(<type-name>) to get the space(byte) that needed to store this type of data.

  • We can use keyword typedef <existing-type-name> <new-name> to rename an existing type, for example:

    typedef unsigned int Uint;
    //Remember that typedef just rename an existing data type, rather than creating a new data type.
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值