当前位置:网站首页>成都測試設備定制_單片機C語言之數據類型初步介紹
成都測試設備定制_單片機C語言之數據類型初步介紹
2022-06-10 09:56:00 【u010755676】
成都測試設備定制提供_單片機C語言之數據類型初步介紹
SO技術分享之33
本文介紹關於C語言中數據類型的相關知識,比如常見的數據類型有哪些,怎麼定義和使用數據類型等。
1、數據的比特是什麼?
計算機系統的存儲最小單元為一個二進制比特,每一比特要麼0要麼1。一般來說,數據的比特指一個數據占用多少個二進制比特。開發定制Q:2531-263-726
2、什麼是數據類型?
在計算機科學和計算機編程中,數據類型或簡單的類型是數據的一個屬性,它告訴編譯器或解釋器程序員打算如何使用數據。
定義數據類型的主要目的是用於編譯器配置數據的存儲空間。
數據類型的一個主要特征是占用多少個二進制比特。
3、為什麼要了解數據類型?
編程一個最主要的工作就是處理數據,數據類型是單片機編程的基礎性問題。
不了解數據類型,編程基本做不了。
4、什麼是有符號數和無符號數?
有符號數,就是既有正也有負的數據。無符號數為只有大於等於0的數據。
5、C語言中常見的數據類型有哪些?

計算機中的數據是以二進制的形式來存儲的,在二進制存儲系統裏,每一比特要麼是0要麼是1,如果要錶示更大的數值那麼就得使用多個比特來組合。
按照存儲的數據比特來分類,單片機C語言裏常見的數據類型如圖 1,一般就是1比特數,8比特數,16比特數,32比特數,64比特數等。
指針和數組稍微複雜一點,後期用到時再詳說。
注意一下,不同的編譯器標識符可能不一樣,圖 1這裏是KEIL的。
6、定義數據類型
定義數據類型的格式為:標識符 變量,或者 標識符 變量=初始值。
定義部分數據類型的例子如下:

7、怎麼使用數據類型
在程序中,數據需要先定義,再使用,並注意在程序運行過程中取值不要超過允許的範圍,不然就出錯。
舉個例子:
unsigned char c=100;//定義字符變量c,並賦初值為100
c=c+50;//將c加50,那麼c=150
c=c+120;//此時會出錯誤。之前已經c=150了,如果將c再加120,按理說c=150+120=270,但是270已經超出無符號字符的取值範圍,所以出錯,c≠270.
小結
數據類型是編程的基礎性問題。在使用過程中,需注意數據類型的匹配和不要超出範圍。
本節完,精彩待續。
边栏推荐
- Mysql database (26): View
- How to handle art record? What materials should be prepared for handling the art record?
- The new domestic golang framework is ready to be released. Come and have a look
- 【蓝桥杯集训100题】scratch苹果熟了 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第13题
- Why should the R & D effectiveness team of Internet companies be independent? When is independence?
- Learning notes on panoramic segmentation of point cloud
- Browser cache forbidden explanation
- Flutter:自定义单选按钮
- Monthly 50 f cocktails (thinking)
- SQL server always on monitoring script and some misunderstandings
猜你喜欢

Demand and business model innovation - demand 15- demand specification

Réflexions sur la conception de la gestion du réseau Unicom 5g

隐私计算重要技术突破!亿级数据密态分析可在10分钟内完成

四种最简单的防反接电路

浏览器禁止缓存讲解

Notes to docker advanced chapter (7) steps to build a redis three master and three slave cluster case in docker

Why is your next computer a computer? Explore different remote operations

Browser cache forbidden explanation

Four simplest anti reverse circuits

Design of smart home control system (onenet) based on stm32_ two thousand and twenty-two
随机推荐
MS COCO数据集
SQL server always on monitoring script and some misunderstandings
When the SQL file exported from the PowerDesigner physical data model is executed, an error occurs?
【边缘检测】基于matlab八方向sobel图像边缘检测【含Matlab源码 1865期】
致广大、尽精微,曙光问道算力服务“神经系统”
Niuke monthly race 50D birthday (calculated contribution)
R language uses coin package to apply permutation tests to continuous variable independence problems, Wilcoxon rank sum test and Wilcox in permutation test on the same data set_ Test exact test
Requirements and business model analysis - Requirements 16 - requirements validation
53. maximum subarray and
osg基本操作
【摸鱼神器】UI库秒变LowCode工具——列表篇(二)维护json的小工具
Uncaught TypeError: Cannot read properties of undefined (reading ‘colspan‘)
R language uses rpart package to build decision tree model, selects appropriate tree size (complexity) to check cptable contents of decision tree objects (tree size is defined by splitting times and p
Lambda expression
Pointnet: deep learning on point sets for 3D classi "location and segmentation
[Timm] an image model library based on pytorch
PHP微信H5支付Demo
【图像特征提取】基于matlab脉冲耦合神经网络(PCNN)图像特征提取【含Matlab源码 1868期】
Notes to docker advanced (6) master-slave replication of MySQL in docker
1143. longest common subsequence