<!DOCTYPE html>
	<html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
	<head>
<title>&#91;C++&#93;. Kiểu Dữ Liệu</title>
<meta name="description" content="&#91;C++&#93;. Kiểu Dữ Liệu - Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;tinhocdct.xyz&#x002F;savefile&#x002F;hoat-dong-chuyen-mon&#x002F;c-kieu-du-lieu-442.html">
<meta name="author" content="TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG">
<meta name="copyright" content="TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG [webmaster@tinhocdct.xyz]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="&#91;C++&#93;. Kiểu Dữ Liệu">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;tinhocdct.xyz&#x002F;savefile&#x002F;hoat-dong-chuyen-mon&#x002F;c-kieu-du-lieu-442.html">
<meta property="og:site_name" content="TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG">
<meta property="og:url" content="https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-kieu-du-lieu-442.html">
<link rel="shortcut icon" href="https://tinhocdct.xyz/favicon.ico">
<link rel="canonical" href="https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-kieu-du-lieu-442.html">
<link rel="alternate" href="https://tinhocdct.xyz/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/tin-tuc/" title="Tin Tức - TIN TỨC" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/thong-cao-bao-chi/" title="Tin Tức - THÔNG BÁO" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/ban-tin-noi-bo/" title="Tin Tức - BẢN TIN NỘI BỘ" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/tin-cong-nghe/" title="Tin Tức - CÔNG NGHỆ - KHOA HỌC" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/thu-thuat/" title="Tin Tức - THỦ THUẬT" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/tien-ich/" title="Tin Tức - TIỆN ÍCH" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/ai/" title="Tin Tức - AI" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/khoa-hoc/" title="Tin Tức - KHOA HỌC" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/hoat-dong-chuyen-mon/" title="Tin Tức - HOẠT ĐỘNG CHUYÊN MÔN" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/hoat-dong-cong-doan/" title="Tin Tức - CÔNG ĐOÀN" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/hoat-dong-doan-the/" title="Tin Tức - ĐOÀN THỂ" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/tuyen-sinh-huong-nghiep/" title="Tin Tức - TUYỂN SINH - HƯỚNG NGHIỆP" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/tuyen-sinh-2025/" title="Tin Tức - TUYỂN SINH 2025" type="application/rss+xml">
<link rel="alternate" href="https://tinhocdct.xyz/rss/lich-cong-tac-tuan/" title="Tin Tức - Lịch công tác tuần" type="application/rss+xml">
<link rel="preload" as="script" href="https://tinhocdct.xyz/assets/js/jquery/jquery.min.js">
<link rel="preload" as="script" href="https://tinhocdct.xyz/assets/js/language/vi.js">
<link rel="preload" as="script" href="https://tinhocdct.xyz/assets/js/global.js">
<link rel="preload" as="script" href="https://tinhocdct.xyz/themes/default/js/news.js">
<link rel="preload" as="script" href="https://tinhocdct.xyz/themes/default/js/main.js">
<link rel="preload" as="script" href="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1816161148536198">
<link rel="preload" as="script" href="https://tinhocdct.xyz/themes/default/js/bootstrap.min.js">
<link rel="StyleSheet" href="https://tinhocdct.xyz/assets/css/font-awesome.min.css">
<link rel="StyleSheet" href="https://tinhocdct.xyz/themes/default/css/bootstrap.non-responsive.css">
<link rel="StyleSheet" href="https://tinhocdct.xyz/themes/default/css/style.css">
<link rel="StyleSheet" href="https://tinhocdct.xyz/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://tinhocdct.xyz/themes/default/css/news.css">
<style>
	body{background: #fff;}
</style>
	</head>
	<body>
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG</h2>
		<p class="pull-right"><a title="TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG" href="https://tinhocdct.xyz/">https://tinhocdct.xyz</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>&#91;C++&#93;. Kiểu Dữ Liệu</h1>
		<ul class="list-inline">
			<li>Thứ sáu - 21/02/2025 03:00</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
			Kiểu Dữ Liệu trong ngôn ngữ lập trình C++ giúp bạn lưu trữ giá trị về số, ký tự, chuỗi ký tự, ... Trong bài viết này cùng mình điểm qua các kiểu dữ liệu chính thông dụng trong ngôn ngữ lập trình C++
		</div>
				<div class="imghome">
			<img alt="kiểu dữ liệu &#40;data type&#41; trong c++" src="https://tinhocdct.xyz/uploads/news/2025_02/kieu-du-lieu-data-type-trong-c.png" width="460" class="img-thumbnail" />
		</div>
		<div class="clear"></div>
		<div id="bodytext" class="clearfix">
			<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span data-mce-style="font-size: 14pt; color: rgb(53, 152, 219);" style="font-size:14pt"><span style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">1. Kiểu Dữ Liệu Số Nguyên</strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Bảng sau liệt kê các kiểu dữ liệu số nguyên phổ biến trong ngôn ngữ lập trình C++&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<table border="1" data-mce-style="border-collapse: collapse; width: 99.9868%;" style="-webkit-text-stroke-width:0px;border-collapse:collapse;box-sizing:border-box;color:rgb(82, 87, 92);font-family:&#039;Be Vietnam Pro&#039;,sans-serif;font-size:15px;font-style:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-weight:400;letter-spacing:normal;max-width:100%;orphans:2;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-decoration-thickness:initial;text-transform:none;white-space:normal;widows:2;width:869.883px;word-spacing:0px;">
	<colgroup style="box-sizing:border-box">
		<col data-mce-style="width: 15.6514%;" style="box-sizing:border-box; width:136.047px">
		<col data-mce-style="width: 11.8788%;" style="box-sizing:border-box; width:103.258px">
		<col data-mce-style="width: 18.1434%;" style="box-sizing:border-box; width:157.711px">
		<col data-mce-style="width: 54.2819%;" style="box-sizing:border-box; width:471.867px">
	</colgroup>
	<tbody style="box-sizing:border-box">
		<tr>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kiểu dữ liệu</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kích thước (byte)</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Giá trị có thể lưu</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Phạm vi giá trị có thể lưu</strong></span></span></span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">short</span></td>
			<td><span style="box-sizing:border-box">2</span></td>
			<td><span style="box-sizing:border-box">Số nguyên</span></td>
			<td><span style="box-sizing:border-box">-32,768 -&gt; 32,767</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">unsigned short</span></td>
			<td><span style="box-sizing:border-box">2&nbsp;</span></td>
			<td><span style="box-sizing:border-box">Số nguyên không âm</span></td>
			<td><span style="box-sizing:border-box">0 -&gt; 65,535</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">int</span></td>
			<td><span style="box-sizing:border-box">4</span></td>
			<td><span style="box-sizing:border-box">Số nguyên</span></td>
			<td><span style="box-sizing:border-box">-2,147,483,648 -&gt; 2,147,483,647</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">unsigned int</span></td>
			<td><span style="box-sizing:border-box">4</span></td>
			<td><span style="box-sizing:border-box">Số nguyên không âm</span></td>
			<td><span style="box-sizing:border-box">0 -&gt; 4,294,967,295</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">long long</span></td>
			<td><span style="box-sizing:border-box">8</span></td>
			<td><span style="box-sizing:border-box">Số nguyên</span></td>
			<td><span style="box-sizing:border-box">-9223372036854775808 -&gt; 9223372036854775807</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">unsigned long long</span></td>
			<td><span style="box-sizing:border-box">8</span></td>
			<td><span style="box-sizing:border-box">Số nguyên không âm</span></td>
			<td><span style="box-sizing:border-box">0 -&gt; 18446744073709551615</span></td>
		</tr>
	</tbody>
</table>
<br style="box-sizing:border-box" />
<br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Dựa theo số byte mà kiểu dữ liệu cần để lưu trữ bạn có thể tính ra phạm vi giá trị mà số nguyên đó có thể lưu trữ.&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Cách tính giới hạn của các kiểu dữ liệu số nguyên như sau : Từ số byte mà kiểu dữ liệu này cần để lưu trữ trong bộ nhớ bạn có thể tính ra số bit mà nó dùng để biểu diễn số nguyên (1 byte bằng 8 bit) . Từ số bit này bạn suy ra như sau</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

<ul style="box-sizing:border-box; margin-bottom:10px; color:rgb(82, 87, 92); font-family:&#039;Be Vietnam Pro&#039;, sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px; -webkit-text-stroke-width:0px; white-space:normal; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial">
	<li style="box-sizing:border-box">Số nguyên có dấu : Kiểu dữ liệu có K bit sẽ lưu được giá trị từ 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">(K - 1)&nbsp;</sup>tới 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">(K-1)</sup>&nbsp;- 1, ví dụ kiểu<strong style="box-sizing:border-box; font-weight:bolder">&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">int</span></span>&nbsp;</strong>có 4 byte tương đương 32 bit sẽ lưu giá trị từ 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">31&nbsp;</sup>tới 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">31</sup>&nbsp;- 1</li>
	<li style="box-sizing:border-box">Số nguyên không dấu : Kiểu dữ liệu có K bit sẽ lưu được giá trị từ 0 tới 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">K</sup>&nbsp;- 1, ví dụ&nbsp;<strong style="box-sizing:border-box; font-weight:bolder"><span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">unsigned int</span></span></strong>&nbsp;có 4 byte sẽ lưu giá trị từ 0 tới 2<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">32</sup>&nbsp;- 1</li>
</ul>
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Thông thường kiểu dữ liệu số nguyên sẽ có kiểu không dấu tương ứng của nó, kiểu dữ liệu số nguyên sẽ sử dụng 1 bit để lưu dấu âm hay dấu dương còn kiểu số nguyên không dấu sẽ không cần bit để lưu dấu nên giải giá trị của nó thường gấp đôi giải giá trị của số nguyên có dấu tương ứng. Ví dụ số nguyên int có 32 bit thì sẽ mất 1 bit để lưu dấu còn 31 bit biểu diễn giá trị số, còn số nguyên unsigned int sẽ dùng cả 32 bit này để biểu diễn số.</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><strong style="box-sizing:border-box; font-weight:bolder"><span data-mce-style="color: rgb(224, 62, 45);" style="box-sizing:border-box"><span style="color:rgb(224, 62, 45);">Một số lưu ý khi sử dụng số nguyên</span></span></strong>&nbsp;:</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

<ul style="box-sizing:border-box; margin-bottom:10px; color:rgb(82, 87, 92); font-family:&#039;Be Vietnam Pro&#039;, sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px; -webkit-text-stroke-width:0px; white-space:normal; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial">
	<li style="box-sizing:border-box">Số nguyên không thể lưu được phần thập phân</li>
	<li style="box-sizing:border-box">Số nguyên sẽ bị tràn giá trị nếu bạn gán cho nó giá trị vượt phạm vi của nó có thể lưu</li>
	<li style="box-sizing:border-box">Thông thường bạn chỉ sử dụng int và long long, ít khi sử dụng short.&nbsp;</li>
	<li style="box-sizing:border-box">Nếu lưu số nguyên từ -2.10<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">9</sup>&nbsp;tới 2.10<sup style="box-sizing:border-box; position:relative; font-size:11.25px; line-height:0; vertical-align:baseline; top:-0.5em">9</sup>&nbsp;thì dùng int là đủ, nếu ngoài phạm vi này dùng long long&nbsp;</li>
</ul>

<hr style="box-sizing:content-box; height:0px; overflow:visible; margin-top:20px; margin-bottom:20px; border-width:1px 0px 0px; border-right-style:initial; border-bottom-style:initial; border-left-style:initial; border-right-color:initial; border-bottom-color:initial; border-left-color:initial; border-image:initial; border-top-style:solid; border-top-color:rgb(225, 225, 225); color:rgb(82, 87, 92); font-family:&#039;Be Vietnam Pro&#039;, sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px; -webkit-text-stroke-width:0px; white-space:normal; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" /><span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span data-mce-style="color: rgb(53, 152, 219); font-size: 14pt;" style="font-size:14pt"><span style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">2. Kiểu Dữ Liệu Số Thực</strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Khi bạn muốn lưu kiểu dữ liệu có phần thập phân bạn cần sử dụng kiểu dữ liệu số thực, trong C++ có 3 kiểu dữ liệu lưu số thực gồm :&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">float</span></span>,&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">double</span></span>,&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">long double</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Khi sử dụng kiểu dữ liệu số thực bạn cần biết các kiểu dữ liệu này có thể lưu được bao nhiêu số sau dấu phảy thập phân để lựa chọn kiểu dữ liệu cho phù hợp với độ chính xác mong muốn của bài toán.&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

<table border="1" data-mce-style="border-collapse: collapse; width: 100.019%;" style="-webkit-text-stroke-width:0px;border-collapse:collapse;box-sizing:border-box;color:rgb(82, 87, 92);font-family:&#039;Be Vietnam Pro&#039;,sans-serif;font-size:15px;font-style:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-weight:400;letter-spacing:normal;max-width:100%;orphans:2;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-decoration-thickness:initial;text-transform:none;white-space:normal;widows:2;width:870px;word-spacing:0px;">
	<colgroup style="box-sizing:border-box">
		<col data-mce-style="width: 22.1182%;" style="box-sizing:border-box; width:192.211px">
		<col data-mce-style="width: 16.2339%;" style="box-sizing:border-box; width:141.078px">
		<col data-mce-style="width: 61.6422%;" style="box-sizing:border-box; width:535.711px">
	</colgroup>
	<tbody style="box-sizing:border-box">
		<tr>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kiểu dữ liệu</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kích thước (byte)</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Độ chính xác</strong></span></span></span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">float</span></td>
			<td><span style="box-sizing:border-box">4</span></td>
			<td><span style="box-sizing:border-box">6 - 9 chữ số thập phân</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">double</span></td>
			<td><span style="box-sizing:border-box">8</span></td>
			<td><span style="box-sizing:border-box">15 - 18 chữ số thập phân&nbsp;</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">long double</span></td>
			<td><span style="box-sizing:border-box">16&nbsp;</span></td>
			<td><span style="box-sizing:border-box">33 - 36 chữ số thập phân</span></td>
		</tr>
	</tbody>
</table>
<br style="box-sizing:border-box" />
<br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Kiểu dữ liệu số thực có thể lưu được số nguyên tuy nhiên bạn không nên sử dụng nó để lưu số nguyên vì bản chất số thực luôn có sai số nhất định và không thể lưu giá trị số thực đúng tuyệt đối 100%. Thông thường thì mình sẽ dùng số thực double trong các bài toán khi kết quả cần lưu phần thập phân.</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

<hr style="box-sizing:content-box; height:0px; overflow:visible; margin-top:20px; margin-bottom:20px; border-width:1px 0px 0px; border-right-style:initial; border-bottom-style:initial; border-left-style:initial; border-right-color:initial; border-bottom-color:initial; border-left-color:initial; border-image:initial; border-top-style:solid; border-top-color:rgb(225, 225, 225); color:rgb(82, 87, 92); font-family:&#039;Be Vietnam Pro&#039;, sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px; -webkit-text-stroke-width:0px; white-space:normal; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" /><span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span data-mce-style="color: rgb(53, 152, 219); font-size: 14pt;" style="font-size:14pt"><span style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">3. Kiểu Dữ Liệu Ký Tự</strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Khi bạn cần lưu trữ một ký tự trong C++ thì bạn sử dụng kiểu dữ liệu char, thực tế&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">char&nbsp;</span></span>cũng được sử dụng để lưu số nguyên.&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Tuy nhiên mỗi ký tự mà bạn thường sử dụng đều có mã ASCII tương ứng, thời điểm hiện tại bạn sẽ chưa biết mã ASCII là gì tuy nhiên bạn chỉ cần nhớ rằng char có thể lưu được số nguyên hoặc lưu được kí tự.&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Các ký tự như : chữ cái, chữ số, kí tự đặc biệt... đều có thể lưu trữ bằng kiểu dữ liệu char</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

<table border="1" data-mce-style="border-collapse: collapse; width: 100.019%;" style="-webkit-text-stroke-width:0px;border-collapse:collapse;box-sizing:border-box;color:rgb(82, 87, 92);font-family:&#039;Be Vietnam Pro&#039;,sans-serif;font-size:15px;font-style:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-weight:400;letter-spacing:normal;max-width:100%;orphans:2;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-decoration-thickness:initial;text-transform:none;white-space:normal;widows:2;width:870px;word-spacing:0px;">
	<colgroup style="box-sizing:border-box">
		<col data-mce-style="width: 16.4287%;" style="box-sizing:border-box; width:142.766px">
		<col data-mce-style="width: 13.5827%;" style="box-sizing:border-box; width:118.039px">
		<col data-mce-style="width: 13.9407%;" style="box-sizing:border-box; width:121.148px">
		<col data-mce-style="width: 56.0424%;" style="box-sizing:border-box; width:487.047px">
	</colgroup>
	<tbody style="box-sizing:border-box">
		<tr>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kiểu dữ liệu</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Kích thước (byte)</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Giá trị có thể lưu</strong></span></span></span></td>
			<td><span style="box-sizing:border-box"><span data-mce-style="color: rgb(53, 152, 219);" style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">Phạm vi giá trị có thể lưu</strong></span></span></span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">char</span></td>
			<td><span style="box-sizing:border-box">1</span></td>
			<td><span style="box-sizing:border-box">Số nguyên hoặc ký tự</span></td>
			<td><span style="box-sizing:border-box">-128 -&gt; 127</span></td>
		</tr>
		<tr>
			<td><span style="box-sizing:border-box">unsigned char</span></td>
			<td><span style="box-sizing:border-box">1</span></td>
			<td><span style="box-sizing:border-box">Số nguyên không âm hoặc ký tự</span></td>
			<td><span style="box-sizing:border-box">0 -&gt; 255</span></td>
		</tr>
	</tbody>
</table>

<hr style="box-sizing:content-box; height:0px; overflow:visible; margin-top:20px; margin-bottom:20px; border-width:1px 0px 0px; border-right-style:initial; border-bottom-style:initial; border-left-style:initial; border-right-color:initial; border-bottom-color:initial; border-left-color:initial; border-image:initial; border-top-style:solid; border-top-color:rgb(225, 225, 225); color:rgb(82, 87, 92); font-family:&#039;Be Vietnam Pro&#039;, sans-serif; font-size:15px; font-style:normal; font-variant-ligatures:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px; -webkit-text-stroke-width:0px; white-space:normal; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" /><span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span data-mce-style="color: rgb(53, 152, 219); font-size: 14pt;" style="font-size:14pt"><span style="box-sizing:border-box"><span style="color:rgb(53, 152, 219);"><strong style="box-sizing:border-box; font-weight:bolder">4. Kiểu Đúng Sai</strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Kiểu đúng sai hay luận lý được sử dụng để lưu trữ giá trị đúng (true) hoặc sai (false)&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Trong ngôn ngữ lập trình C++ thì kiểu&nbsp;<span data-mce-style="color: rgb(230, 126, 35);" style="box-sizing:border-box"><span style="color:rgb(230, 126, 35);">bool&nbsp;</span></span>được sử dụng để lưu các giá trị đúng sai.&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
<span style="font-size:15px"><span style="box-sizing:border-box"><span style="color:rgb(82, 87, 92);"><span style="font-family:&#039;Be Vietnam Pro&#039;, sans-serif"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-variant-caps:normal"><span style="font-weight:400"><span style="letter-spacing:normal"><span style="orphans:2"><span style="text-transform:none"><span style="widows:2"><span style="word-spacing:0px"><span style="white-space:normal"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial">Kiểu dữ liệu này có kích thước là 1 byte&nbsp;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br  />
&nbsp;
<div><a href="https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-chuong-trinh-hello-world-441.html" target="_blank"><img alt="bai truoc" height="35" src="https://tinhocdct.xyz/uploads/news/2025_02/bai-truoc.png" width="120" /></a><a href="https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-chu-thich-comment-444.html" target="_blank"><img alt="bai tiep" height="35" src="https://tinhocdct.xyz/uploads/news/2025_02/bai-tiep.png" style="float:right" width="120" /></a></div>
&nbsp;
		</div>
				<div id="author">
						<p>
				<strong>Tác giả bài viết:</strong>
				Thanh Sơn
			</p>
						<p>
				<strong>Nguồn tin:</strong>
				blog.28tech.com.vn
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-kieu-du-lieu-442.html" title="&#91;C++&#93;. Kiểu Dữ Liệu">https://tinhocdct.xyz/hoat-dong-chuyen-mon/c-kieu-du-lieu-442.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; TỔ TIN HỌC TRƯỜNG THPT ĐỖ CÔNG TƯỜNG
		</div>
		<div id="contact">
			<a href="mailto:webmaster@tinhocdct.xyz">webmaster@tinhocdct.xyz</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://tinhocdct.xyz/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<script src="https://tinhocdct.xyz/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv4",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_is_recaptcha=0;</script>
<script src="https://tinhocdct.xyz/assets/js/language/vi.js"></script>
<script src="https://tinhocdct.xyz/assets/js/global.js"></script>
<script src="https://tinhocdct.xyz/themes/default/js/news.js"></script>
<script src="https://tinhocdct.xyz/themes/default/js/main.js"></script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1816161148536198"
     crossorigin="anonymous"></script>
<script src="https://tinhocdct.xyz/themes/default/js/bootstrap.min.js"></script>
</body>
</html>