High School Computer Science

Boolean Logic and Number Systems布尔逻辑与数制

Computers speak in binary: every piece of data — a number, a letter, an image — is ultimately a string of 0s and 1s. This guide builds the full picture from the ground up: how the binary number system works and why base-2 maps perfectly onto hardware; how hexadecimal gives programmers a compact shorthand; how to convert fluently between decimal, binary, and hex; how to add in binary; how text is encoded as ASCII and Unicode; and how Boolean logic — AND, OR, NOT — connects the world of numbers to the logic gates that make up every circuit. Truth tables appear throughout so you can reason about any logical expression by hand.计算机用二进制(binary,二进制)"说话":每一份数据——数字、字母、图像——最终都是一串 0 和 1。本指南从零开始建立完整体系:二进制数制(binary number system)如何工作,以及为何以 2 为底完美地映射到硬件;十六进制(hexadecimal,十六进制)如何给程序员提供紧凑的简写;如何在十进制(decimal,十进制)、二进制和十六进制之间流畅转换;如何做二进制加法;文本如何被编码为 ASCII 和 Unicode;以及布尔逻辑(Boolean logic,布尔逻辑)——与(AND)、或(OR)、非(NOT)——如何将数字世界与构成每个电路的逻辑门(logic gate,逻辑门)连接起来。真值表(truth table,真值表)贯穿全文,使你能够手工推理任意逻辑表达式。

7 sections7 节内容 US CSTA · AP CSP · ON · BC · ABUS CSTA · AP CSP · ON · BC · AB Tables + worked conversions表格 + 例题转换

How to use this guide如何使用本指南

Boolean logic and number systems appear in all four curricula, though with varying depth. Ontario ICS3U is the most explicit: A1.2 names binary, hexadecimal, ASCII, and Unicode verbatim; A1.4 names AND, OR, NOT verbatim. US CSTA 3A-DA-09 links bit representation to characters, numbers, images, and explicitly mentions logic gates in its Descriptive Statement. AP CSP Big Idea 2 (Data) covers binary numbers and bit representation (topics 2.1–2.2). BC names Boolean operators in Computer Studies 10 but has no explicit binary/hex conversion standard. Alberta names Boolean operators in CSE1120 and ASCII/binary encoding in CSE2130 but has no dedicated number-systems module. The table below maps each section to your curriculum.布尔逻辑和数制在四套课程中均有出现,但深度各异。安大略 ICS3U 最为明确:A1.2 原文点名二进制、十六进制、ASCII 和 Unicode;A1.4 原文点名 AND、OR、NOT。美国 CSTA 3A-DA-09 将位表示与字符、数字、图像关联,其描述性说明明确提及逻辑门。AP CSP 大概念 2(数据)涵盖二进制数和位表示(主题 2.1–2.2)。BC 在 Computer Studies 10 中命名了布尔运算符,但无明确的二进制/十六进制转换标准。阿尔伯塔在 CSE1120 中命名了布尔运算符、在 CSE2130 中命名了 ASCII/二进制编码,但无专门的数制模块。下表将每节内容映射到你的课程。

If you are in…如果你在… Focus on these sections重点学习 Defer / lighter可推迟 / 减负 Source依据
🇺🇸 US CSTA / AP CSP美国 CSTA / AP CSP §1–§5 (binary, hex, conversions, ASCII/Unicode, bit/byte) are the core of AP CSP Big Idea 2 (DAT-1.A, DAT-1.B). §6–§7 (Boolean logic, gates) map to CSTA 3A-DA-09 Descriptive Statement and 3B-CS-02.§1–§5(二进制、十六进制、转换、ASCII/Unicode、位/字节)是 AP CSP 大概念 2(DAT-1.A、DAT-1.B)的核心。§6–§7(布尔逻辑、逻辑门)对应 CSTA 3A-DA-09 描述性说明和 3B-CS-02。 Logic gate circuit diagrams (§7 going-deeper) are enrichment for AP CSP students; the exam tests Boolean expressions, not physical gate drawing.逻辑门电路图(§7 深入)对 AP CSP 学生为拓展内容;考试测试布尔表达式,而非物理门图。 CSTA K-12 and AP CSP — CSTA 3A-DA-09, 3B-CS-02; AP CSP Big Idea 2 (DAT) topics 2.1, 2.2— CSTA 3A-DA-09、3B-CS-02;AP CSP 大概念 2(DAT)主题 2.1、2.2
🇨🇦 ON Grade 11 — ICS3U安大略 11 年级 — ICS3U All seven sections. ICS3U A1.2 explicitly names binary, hex, ASCII, Unicode (§1–§5). ICS3U A1.4 explicitly names AND, OR, NOT (§6–§7). The most direct curriculum match of all four regions.全部 7 节。ICS3U A1.2 明确点名二进制、十六进制、ASCII、Unicode(§1–§5)。ICS3U A1.4 明确点名 AND、OR、NOT(§6–§7)。四个地区中课程匹配度最高。 Nothing — the whole unit is assessed in ICS3U Strand A.无——整个单元均在 ICS3U A 单元中评估。 ON/BC Computer Studies 11-12 — ICS3U A1.2, A1.4— ICS3U A1.2、A1.4
🇨🇦 BC — CS10 / CIS11BC — CS10 / CIS11 §6 (Boolean logic: AND, OR, NOT) is the strongest curriculum match (CS10 intro-constructs Content). §5 (ASCII/Unicode, bit/byte) connects to CIS11 data-encoding Content. §1–§4 (binary/hex/conversion) are conceptual enrichment — BC has no explicit base-conversion standard.§6(布尔逻辑:AND、OR、NOT)是课程匹配度最高的(CS10 入门构造内容)。§5(ASCII/Unicode、位/字节)与 CIS11 数据编码内容关联。§1–§4(二进制/十六进制/转换)为概念拓展——BC 无明确的进制转换标准。 §7 logic gates going-deeper is enrichment for BC; BC names Boolean operators as a programming construct, not as circuit-level hardware.§7 逻辑门深入对 BC 为拓展;BC 将布尔运算符命名为编程构造,而非电路级硬件。 ON/BC Computer Studies 11-12 — BC CS10 Boolean operators content bullet; CIS11 data encoding content— BC CS10 布尔运算符内容条目;CIS11 数据编码内容
🇨🇦 AB — CSE1120 / CSE2130阿尔伯塔 — CSE1120 / CSE2130 §6 (Boolean operators in programs, CSE1120 outcome 2.6) and §5 (ASCII/binary encoding, CSE2130 outcome 1.1.2) are the assessed content. §1–§4 (binary/hex/arithmetic) are enrichment — Alberta CSE has no dedicated number-base module.§6(程序中的布尔运算符,CSE1120 结果 2.6)和 §5(ASCII/二进制编码,CSE2130 结果 1.1.2)是被评估的内容。§1–§4(二进制/十六进制/算术)为拓展——阿尔伯塔 CSE 无专门的进制模块。 §7 (logic gates) is enrichment for AB; digital logic / number systems are in other CTS clusters, not CSE.§7(逻辑门)对 AB 为拓展;数字逻辑/数制在其他 CTS 集群中,不在 CSE 中。 Alberta CTS Computing Science — CSE1120 outcomes 2.3, 2.6; CSE2130 outcome 1.1.2— CSE1120 结果 2.3、2.6;CSE2130 结果 1.1.2
!
If you are cramming the night before如果你在临阵磨枪

Memorise five things: how to count in binary and convert a small number to/from decimal; what a bit and byte are; the three Boolean operators AND, OR, NOT and their truth tables; what ASCII is; and how to evaluate a simple Boolean expression. Read every cram-cheat box. Skip the logic gate circuit diagrams in §7 going-deeper.背熟五件事:如何用二进制计数并将小数字与十进制互转;位和字节是什么;AND、OR、NOT 三个布尔运算符及其真值表;ASCII 是什么;以及如何求一个简单布尔表达式的值。读每个速记框,跳过 §7 深入中的逻辑门电路图。

*
If you are going for the top mark如果你目标顶分

Master fluent conversion in all three directions (binary ↔ decimal ↔ hex). Be able to construct a full truth table for a compound expression like (A AND B) OR (NOT C). Understand why each binary digit doubles the representable range. Know the Unicode extension story beyond ASCII. AP CSP DAT-1.A and DAT-1.B, and Ontario ICS3U A1.2 + A1.4, are the exam anchors for full marks.掌握三个方向的流畅转换(二进制 ↔ 十进制 ↔ 十六进制)。能够为复合表达式(如 (A AND B) OR (NOT C))构建完整真值表。理解为何每个二进制位将可表示范围翻倍。了解 ASCII 之外的 Unicode 扩展故事。AP CSP DAT-1.A 和 DAT-1.B 以及安大略 ICS3U A1.2 + A1.4 是满分的考试锚点。


The Binary Number System二进制数制

Why binary? Hardware switches have two states: on (1) and off (0). Every decimal number maps to a unique sequence of 1s and 0s.为什么用二进制?硬件开关只有两种状态:开(1)和关(0)。每个十进制数都能唯一映射为一串 1 和 0。
  • Bit位(bit) — a single binary digit: 0 or 1.— 单个二进制位:0 或 1。
  • Byte字节(byte) — 8 bits. 1 byte can represent 28 = 256 distinct values (0–255).— 8 位。1 字节可表示 28 = 256 个不同值(0–255)。
  • Place values double left-to-right位权从右往左翻倍 — in decimal, columns are 1, 10, 100, 1000. In binary they are 1, 2, 4, 8, 16, 32, 64, 128.— 十进制中各列位权为 1、10、100、1000;二进制中为 1、2、4、8、16、32、64、128。
Key fact (AP CSP DAT-1.A): "Data can be represented using bits." Each additional bit doubles the number of possible values: 1 bit = 2 values; 8 bits = 256 values; 16 bits = 65,536 values; 32 bits ≈ 4 billion values.关键事实(AP CSP DAT-1.A):"数据可以用位来表示。"每增加一位,可表示的值的数量翻倍:1 位 = 2 个值;8 位 = 256 个值;16 位 = 65,536 个值;32 位 ≈ 40 亿个值。
WE
Worked Example 1 · Binary place-value table例题 1 · 二进制位权表

Read the 8-bit number 10110101 and find its decimal value.读取 8 位二进制数 10110101,求其十进制值。

Bit position位位置76543210
Place value (2n)位权(2n1286432168421
Bit10110101
Contribution贡献值128032160401

Sum: 128 + 32 + 16 + 4 + 1 = 181.求和:128 + 32 + 16 + 4 + 1 = 181

Each 1-bit contributes its place value; 0-bits contribute nothing. Add up only the columns where the bit is 1.每个 1 位贡献其位权;0 位不贡献任何值。只将位为 1 的列的位权相加。

What is the decimal value of the binary number 1010?二进制数 1010 的十进制值是多少?
§1 · Q1
44
88
1010
1212
Place values for 1010: bit 3 = 8 (1×8), bit 2 = 4 (0×4), bit 1 = 2 (1×2), bit 0 = 1 (0×1). Sum = 8 + 0 + 2 + 0 = 10.1010 各位权:第 3 位 = 8(1×8),第 2 位 = 4(0×4),第 1 位 = 2(1×2),第 0 位 = 1(0×1)。总和 = 8 + 0 + 2 + 0 = 10。
Place values in binary (right to left): 1, 2, 4, 8. For 1010: only bits at positions 3 and 1 are 1. 8 + 2 = 10.二进制位权(从右到左):1、2、4、8。对于 1010:仅第 3 位和第 1 位为 1。8 + 2 = 10。
How many distinct values can be represented with 4 bits?4 位二进制可以表示多少个不同的值?
§1 · Q2
88
1616
3232
44
n bits can represent 2n distinct values. 24 = 16 (values 0000 through 1111, i.e. decimal 0–15). AP CSP DAT-1.A: "Each additional bit doubles the number of possible values."n 位可表示 2n 个不同值。24 = 16(值从 0000 到 1111,即十进制 0–15)。AP CSP DAT-1.A:"每增加一位,可能值的数量翻倍。"
n bits = 2n values. 4 bits = 24 = 16. Each bit added doubles the count.n 位 = 2n 个值。4 位 = 24 = 16。每增加一位,数量翻倍。

Hexadecimal十六进制

Hex (base 16) is a compact shorthand for binary: each hex digit represents exactly 4 bits (a nibble).十六进制(以 16 为底)是二进制的紧凑缩写:每个十六进制位恰好代表 4 位(半字节,nibble)。
  • Digits: 0–9 then A=10, B=11, C=12, D=13, E=14, F=15.数字:0–9,然后 A=10、B=11、C=12、D=13、E=14、F=15。
  • One byte (8 bits) = exactly 2 hex digits. e.g. 0xFF = 1111 1111 = decimal 255.一字节(8 位)= 恰好 2 个十六进制位。例如 0xFF = 1111 1111 = 十进制 255。
  • Hex prefix: 0x in code (e.g. 0x1F); # in HTML color codes (e.g. #FF0000 = pure red).十六进制前缀:代码中用 0x(如 0x1F);HTML 颜色代码中用 #(如 #FF0000 = 纯红色)。
CSTA 3A-DA-09 Descriptive Statement (verbatim): "For example, convert hexadecimal color codes to decimal percentages, ASCII/Unicode representation, and logic gates." Hex color codes are the most visible real-world use of hexadecimal.CSTA 3A-DA-09 描述性说明(原文):"例如,将十六进制颜色代码转换为十进制百分比、ASCII/Unicode 表示及逻辑门。"十六进制颜色代码是十六进制最直观的现实应用。
WE
Worked Example 2 · Hex digit table and color code例题 2 · 十六进制数字表与颜色代码

Show the 16 hex digits and their binary/decimal equivalents, then decode the color #3A7FBE.列出 16 个十六进制数字及其对应的二进制/十进制值,然后解码颜色代码 #3A7FBE。

Hex十六进制Decimal十进制4-bit binary4 位二进制Hex十六进制Decimal十进制4-bit binary4 位二进制
000000881000
110001991001
220010A101010
330011B111011
440100C121100
550101D131101
660110E141110
770111F151111

Decoding #3A7FBE (RGB color):解码 #3A7FBE(RGB 颜色):

#3A7FBE  →  R=0x3A  G=0x7F  B=0xBE
R: 3=0011, A=1010  →  0011 1010  =  58  (decimal)
G: 7=0111, F=1111  →  0111 1111  =  127 (decimal)
B: B=1011, E=1110  →  1011 1110  =  190 (decimal)

Each pair of hex digits is one byte (0–255). The color #3A7FBE has red=58, green=127, blue=190 — a medium steel-blue.每对十六进制位代表一字节(0–255)。颜色 #3A7FBE 的红色=58、绿色=127、蓝色=190——一种中等钢蓝色。

What is the decimal value of the hex digit B?十六进制数字 B 的十进制值是多少?
§2 · Q1
1111
1212
1010
1616
Hex digits A=10, B=11, C=12, D=13, E=14, F=15. B = 11.十六进制数字:A=10、B=11、C=12、D=13、E=14、F=15。B = 11。
A=10, B=11, C=12, D=13, E=14, F=15. Memorise this mapping.A=10、B=11、C=12、D=13、E=14、F=15。记住这个对应关系。
How many bits does one hex digit represent?一个十六进制位代表多少位二进制?
§2 · Q2
11
22
88
44
One hex digit represents 4 bits (a nibble), because 16 = 24. Two hex digits = one byte (8 bits).一个十六进制位代表 4 位二进制(半字节),因为 16 = 24。两个十六进制位 = 一字节(8 位)。
Hex base is 16 = 24, so one hex digit encodes 4 bits. Two hex digits = 8 bits = 1 byte.十六进制底数为 16 = 24,故一个十六进制位编码 4 位二进制。两个十六进制位 = 8 位 = 1 字节。

Converting Between Bases进制转换

Three conversions to master: decimal → binary, binary → decimal, binary ↔ hex.需掌握三种转换:十进制 → 二进制、二进制 → 十进制、二进制 ↔ 十六进制。
  • Binary → Decimal二进制 → 十进制 — multiply each bit by its place value (1, 2, 4, 8, …) and sum.— 每位乘以其位权(1、2、4、8……)后求和。
  • Decimal → Binary十进制 → 二进制 — divide by 2 repeatedly; remainders (read bottom-up) are the binary digits.— 反复除以 2;余数(从下往上读)即为二进制位。
  • Binary ↔ Hex二进制 ↔ 十六进制 — group bits in fours from the right; look up each group in the hex table.— 从右侧起每 4 位分为一组;在十六进制表中查找每组的值。
Ontario ICS3U A1.2 (verbatim): "demonstrate an understanding of how a computer uses various systems (e.g., binary, hexadecimal, ASCII, Unicode) to internally represent data." Fluent conversion is the assessed skill.安大略 ICS3U A1.2(原文):"展示对计算机如何使用各种系统(如二进制、十六进制、ASCII、Unicode)在内部表示数据的理解。"流畅转换是被评估的技能。
WE
Worked Example 3 · Decimal 45 in binary and hex例题 3 · 十进制 45 转换为二进制和十六进制

Convert decimal 45 to (a) binary and (b) hexadecimal.将十进制 45 转换为 (a) 二进制和 (b) 十六进制。

(a) Decimal 45 → Binary (repeated division by 2).(a) 十进制 45 → 二进制(反复除以 2)。

45 ÷ 2 = 22 remainder 1   ← least significant bit (LSB)
22 ÷ 2 = 11 remainder 0
11 ÷ 2 =  5 remainder 1
 5 ÷ 2 =  2 remainder 1
 2 ÷ 2 =  1 remainder 0
 1 ÷ 2 =  0 remainder 1   ← most significant bit (MSB)

Read remainders bottom-up: 101101
Pad to 8 bits: 00101101

Check: 32 + 8 + 4 + 1 = 45. Correct.验证:32 + 8 + 4 + 1 = 45。正确。

(b) Binary 00101101 → Hex (group into nibbles).(b) 二进制 00101101 → 十六进制(分成半字节)。

0010 | 1101
  2  |  D
Result: 0x2D

Left nibble 0010 = 2; right nibble 1101 = 13 = D. So 45 decimal = 0x2D hex.左半字节 0010 = 2;右半字节 1101 = 13 = D。因此十进制 45 = 十六进制 0x2D。

What is decimal 13 in binary?十进制 13 的二进制是什么?
§3 · Q1
1100
1101
1110
1011
13 = 8 + 4 + 1 = 1×8 + 1×4 + 0×2 + 1×1 = 1101. Or: 13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1 → read up: 1101.13 = 8 + 4 + 1 = 1×8 + 1×4 + 0×2 + 1×1 = 1101。或:13÷2=6 余1,6÷2=3 余0,3÷2=1 余1,1÷2=0 余1 → 从下往上读:1101。
1100 = 12; 1110 = 14; 1011 = 11. For 13: 8+4+1=13 → bits 3,2,0 are 1 → 1101.1100 = 12;1110 = 14;1011 = 11。对于 13:8+4+1=13 → 第 3、2、0 位为 1 → 1101。
Convert binary 11110000 to hexadecimal.将二进制 11110000 转换为十六进制。
§3 · Q2
0xEF
0xFF
0xF0
0x0F
Split: 1111 | 0000. Left nibble 1111 = 15 = F. Right nibble 0000 = 0. Result: 0xF0.分组:1111 | 0000。左半字节 1111 = 15 = F。右半字节 0000 = 0。结果:0xF0。
Group 4 bits at a time: 1111=F and 0000=0. So 11110000 = 0xF0. EF would be 11101111; FF would be 11111111.每 4 位分一组:1111=F,0000=0。所以 11110000 = 0xF0。EF 对应 11101111;FF 对应 11111111。

Binary Arithmetic (Addition)二进制算术(加法)

Binary addition has four cases only:二进制加法只有四种情况:
  • 0 + 0 = 0 (no carry)(无进位)
  • 0 + 1 = 1 (no carry)(无进位)
  • 1 + 0 = 1 (no carry)(无进位)
  • 1 + 1 = 10 (write 0, carry 1 — exactly like decimal 9+1=10 but happens at 2 not 10)(写 0,进位 1——就像十进制中 9+1=10,但在 2 而不是 10 时发生)
Overflow: if the result needs more bits than are available, the leading bits are lost. This is a fundamental data-representation constraint. AP CSP DAT-1.B: "Explain the consequences of using bits to represent data" — overflow is one such consequence.溢出(overflow):如果结果需要的位数超过可用位数,最高位将丢失。这是位表示数据的根本限制。AP CSP DAT-1.B:"解释用位表示数据的后果"——溢出就是其中一种后果。
WE
Worked Example 4 · Adding binary numbers例题 4 · 二进制数相加

Calculate (a) 0110 + 0101 and (b) 1101 + 0111 in binary. Check against decimal.计算二进制 (a) 0110 + 0101 和 (b) 1101 + 0111。与十进制结果对照验证。

(a) 0110 + 0101 (= decimal 6 + 5 = 11).(a) 0110 + 0101(= 十进制 6 + 5 = 11)。

  0 1 1 0
+ 0 1 0 1
---------
  carry: 0 1 1 0

Step by step (right to left):
  bit 0: 0+1 = 1, carry 0
  bit 1: 1+0 = 1, carry 0
  bit 2: 1+1 = 0, carry 1
  bit 3: 0+0+1(carry) = 1, carry 0

Result: 1011  (= 8+2+1 = 11 decimal) ✓

(b) 1101 + 0111 (= decimal 13 + 7 = 20).(b) 1101 + 0111(= 十进制 13 + 7 = 20)。

  1 1 0 1
+ 0 1 1 1
---------
  bit 0: 1+1 = 0, carry 1
  bit 1: 0+1+1 = 0, carry 1
  bit 2: 1+1+1 = 1, carry 1
  bit 3: 1+0+1 = 0, carry 1

Result: 1 0100  (5 bits needed)
Binary: 10100 = 16+4 = 20 decimal ✓

If restricted to 4-bit storage, the carry-out bit is lost and the result would be 0100 = 4 — an overflow error.如果限制为 4 位存储,进位位丢失,结果将是 0100 = 4——这是一个溢出错误。

What is 0011 + 0101 in binary?二进制 0011 + 0101 的结果是什么?
§4 · Q1
0110
0111
1001
1000
3 + 5 = 8. In binary: bit0: 1+1=0 carry1; bit1: 1+0+1=0 carry1; bit2: 0+1+1=0 carry1; bit3: 0+0+1=1. Result: 1000 = 8. ✓3 + 5 = 8。二进制:第 0 位:1+1=0 进 1;第 1 位:1+0+1=0 进 1;第 2 位:0+1+1=0 进 1;第 3 位:0+0+1=1。结果:1000 = 8。✓
0011=3, 0101=5, sum=8=1000 in binary. Work right to left with carries: 1+1=10, 1+0+carry=10, 0+1+carry=10, 0+0+carry=1. Result 1000.0011=3,0101=5,和=8=二进制 1000。从右到左处理进位:1+1=10,1+0+进位=10,0+1+进位=10,0+0+进位=1。结果 1000。
In binary addition, what is 1 + 1?在二进制加法中,1 + 1 等于什么?
§4 · Q2
10 (write 0, carry 1)10(写 0,进位 1)
22
1111
11
In binary, 1+1 = 2 decimal, but 2 in binary is written 10. Write the 0, carry the 1 to the next column. This is the fundamental carry rule in binary addition.在二进制中,1+1 = 十进制 2,但二进制中 2 写作 10。写下 0,将 1 进位到下一列。这是二进制加法的基本进位规则。
Binary only has 0 and 1. 1+1 exceeds 1, so like decimal 9+1 causing a carry, binary 1+1=10 (write 0, carry 1).二进制只有 0 和 1。1+1 超过 1,就像十进制 9+1 引起进位一样,二进制 1+1=10(写 0,进位 1)。

Representing Text and Data (ASCII, Unicode, Bits and Bytes)文本与数据表示(ASCII、Unicode、位与字节)

Every character is stored as a number. Two encoding standards matter:每个字符都以数字形式存储。两个编码标准至关重要:
  • ASCIIASCII — 7 bits, 128 characters (0–127). Covers A–Z, a–z, 0–9, punctuation, and control codes. 'A' = 65, 'a' = 97, '0' = 48.— 7 位,128 个字符(0–127)。涵盖 A–Z、a–z、0–9、标点和控制字符。'A' = 65,'a' = 97,'0' = 48。
  • UnicodeUnicode — superset of ASCII; over 140,000 characters covering virtually every writing system (Chinese, Arabic, emoji, …). Common encoding: UTF-8 (variable 1–4 bytes; first 128 code points are identical to ASCII).— ASCII 的超集;超过 140,000 个字符,涵盖几乎所有书写系统(中文、阿拉伯文、表情符号……)。常见编码:UTF-8(可变 1–4 字节;前 128 个码点与 ASCII 完全相同)。
  • Bit and byte scale位与字节的换算 — 1 byte = 8 bits; 1 KB = 1,024 bytes; 1 MB = 1,024 KB; 1 GB = 1,024 MB.— 1 字节 = 8 位;1 KB = 1,024 字节;1 MB = 1,024 KB;1 GB = 1,024 MB。
Ontario ICS3U A1.2 (verbatim): "…ASCII, Unicode…" — both encoding standards named. Alberta CSE2130 outcome 1.1.2 (verbatim): "type of data; e.g., text (encoded in a format such as ASCII code), binary (encoded in binary code)."安大略 ICS3U A1.2(原文):"……ASCII、Unicode……"——两个编码标准均被点名。阿尔伯塔 CSE2130 结果 1.1.2(原文):"数据类型;例如,文本(以 ASCII 码等格式编码)、二进制(以二进制代码编码)。"
WE
Worked Example 5 · ASCII encoding of "Hi"例题 5 · "Hi" 的 ASCII 编码

Show how the two-character string "Hi" is stored in memory using ASCII, in both decimal and binary.展示双字符字符串"Hi"如何用 ASCII 在内存中存储,包括十进制和二进制形式。

Character字符ASCII decimalASCII 十进制Binary (8-bit)二进制(8 位)Hex十六进制
'H'72010010000x48
'i'105011010010x69

Storage: 2 characters × 1 byte = 2 bytes = 16 bits total.存储:2 个字符 × 1 字节 = 2 字节 = 共 16 位。

Note: 'H' (uppercase) = 72, 'h' (lowercase) = 104. The difference is 32, which means lowercase = uppercase + 32 in ASCII — a useful pattern for case-conversion code.注意:'H'(大写)= 72,'h'(小写)= 104。差值为 32,即 ASCII 中小写 = 大写 + 32——这是大小写转换代码的有用规律。

Why Unicode extends ASCII.为什么 Unicode 扩展了 ASCII。 ASCII's 128 code points cannot represent Chinese characters, Arabic script, or emoji. Unicode assigns a unique code point to every character in every writing system. UTF-8 encodes the first 128 Unicode code points identically to ASCII (backward-compatible), then uses 2–4 bytes for the rest. The Chinese character 中 is Unicode code point U+4E2D, encoded in UTF-8 as three bytes: 0xE4 0xB8 0xAD.ASCII 的 128 个码点无法表示汉字、阿拉伯文字或表情符号。Unicode 为每种书写系统中的每个字符分配唯一码点。UTF-8 将前 128 个 Unicode 码点与 ASCII 完全相同地编码(向后兼容),其余使用 2–4 字节。汉字"中"是 Unicode 码点 U+4E2D,在 UTF-8 中编码为三字节:0xE4 0xB8 0xAD。

The ASCII code for 'A' is 65. What is the ASCII code for 'B'?字符 'A' 的 ASCII 码为 65。'B' 的 ASCII 码是多少?
§5 · Q1
6464
9797
6666
9898
ASCII codes for uppercase letters are consecutive: A=65, B=66, C=67, … Z=90. Each letter is one more than the previous.大写字母的 ASCII 码是连续的:A=65、B=66、C=67……Z=90。每个字母比前一个多 1。
A=65, so B=66 (consecutive). 97 = lowercase 'a'. 98 = lowercase 'b'. ASCII uppercase letters run 65–90.A=65,所以 B=66(连续)。97 = 小写 'a'。98 = 小写 'b'。ASCII 大写字母范围为 65–90。
Which statement about Unicode and ASCII is correct?关于 Unicode 和 ASCII,哪个说法是正确的?
§5 · Q2
Unicode replaced ASCII entirely; ASCII is no longer usedUnicode 完全取代了 ASCII;ASCII 已不再使用
Unicode is a superset of ASCII; the first 128 code points are identicalUnicode 是 ASCII 的超集;前 128 个码点完全相同
Unicode uses 7 bits per character, same as ASCIIUnicode 每个字符使用 7 位,与 ASCII 相同
ASCII can represent all characters that Unicode canASCII 可以表示 Unicode 所能表示的所有字符
Unicode is a superset of ASCII. The first 128 Unicode code points (U+0000 to U+007F) are identical to ASCII, making UTF-8 backward-compatible with ASCII text. Unicode extends far beyond ASCII to cover over 140,000 characters.Unicode 是 ASCII 的超集。前 128 个 Unicode 码点(U+0000 到 U+007F)与 ASCII 完全相同,使 UTF-8 与 ASCII 文本向后兼容。Unicode 远超 ASCII,涵盖超过 140,000 个字符。
Unicode extends ASCII (does not replace it); the first 128 code points are identical. Unicode uses variable-width encoding (1–4 bytes in UTF-8), not a fixed 7 bits.Unicode 扩展了 ASCII(而非取代);前 128 个码点完全相同。Unicode 使用可变宽度编码(UTF-8 中为 1–4 字节),而非固定 7 位。

Boolean Logic: AND, OR, NOT布尔逻辑:与、或、非

Boolean values are TRUE or FALSE only. Three fundamental operators:布尔值只有 TRUE(真)或 FALSE(假)。三个基本运算符:
  • ANDAND(与) — result is TRUE only when both inputs are TRUE. In code: A and B.— 只有当两个输入都为 TRUE 时结果才为 TRUE。代码中:A and B
  • OROR(或) — result is TRUE when at least one input is TRUE. In code: A or B.— 当至少一个输入为 TRUE 时结果为 TRUE。代码中:A or B
  • NOTNOT(非) — flips the input: NOT TRUE = FALSE, NOT FALSE = TRUE. In code: not A.— 取反:NOT TRUE = FALSE,NOT FALSE = TRUE。代码中:not A
Ontario ICS3U A1.4 (verbatim): "demonstrate the ability to use Boolean operators (e.g., AND, OR, NOT) … correctly in computer programs." Alberta CSE1120 outcome 2.6 (verbatim): "use … Boolean … operators … to process data." BC Computer Studies 10 Content (verbatim): "…Boolean operators, comparison operators…"安大略 ICS3U A1.4(原文):"展示在计算机程序中正确使用布尔运算符(如 AND、OR、NOT)……的能力。"阿尔伯塔 CSE1120 结果 2.6(原文):"使用……布尔……运算符……来处理数据。"BC Computer Studies 10 内容(原文):"……布尔运算符、比较运算符……"
WE
Worked Example 6 · Truth tables for AND, OR, NOT例题 6 · AND、OR、NOT 的真值表

Build the truth tables for all three operators and evaluate the expression (A AND B) OR (NOT C) for A=T, B=F, C=F.为三个运算符建立真值表,并求 A=T、B=F、C=F 时表达式 (A AND B) OR (NOT C) 的值。

AND truth tableAND(与)真值表

ABA AND B
TTT
TFF
FTF
FFF

OR truth tableOR(或)真值表

ABA OR B
TTT
TFT
FTT
FFF

NOT: NOT T = F; NOT F = T.NOT(非):NOT T = F;NOT F = T。

Evaluating (A AND B) OR (NOT C) with A=T, B=F, C=F:求 A=T、B=F、C=F 时 (A AND B) OR (NOT C) 的值:

Step 1: A AND B  = T AND F = F
Step 2: NOT C    = NOT F   = T
Step 3: F OR T             = T

Result: TRUE

Evaluate inside parentheses first, then combine with the outer operator — same operator-precedence rule as arithmetic.先求括号内的值,再与外层运算符结合——与算术中的运算符优先级规则相同。

What is the result of TRUE AND FALSE?TRUE AND FALSE 的结果是什么?
§6 · Q1
TRUETRUE
It depends on the context取决于上下文
FALSEFALSE
TRUE or FALSE randomly随机为 TRUE 或 FALSE
AND requires BOTH inputs to be TRUE. Since B=FALSE, the result is FALSE regardless of A. AND is only TRUE when all inputs are TRUE.AND 要求两个输入都为 TRUE。由于 B=FALSE,无论 A 为何值,结果都是 FALSE。AND 只有在所有输入均为 TRUE 时才为 TRUE。
AND = TRUE only when BOTH inputs are TRUE. TRUE AND FALSE has one FALSE input, so the result is FALSE.AND = 只有当两个输入都为 TRUE 时才为 TRUE。TRUE AND FALSE 有一个 FALSE 输入,所以结果为 FALSE。
Evaluate: NOT (FALSE OR FALSE)求值:NOT (FALSE OR FALSE)
§6 · Q2
TRUETRUE
FALSEFALSE
Cannot be determined无法确定
ERROR错误
Step 1: FALSE OR FALSE = FALSE (OR is only TRUE when at least one input is TRUE). Step 2: NOT FALSE = TRUE.步骤 1:FALSE OR FALSE = FALSE(OR 只有至少一个输入为 TRUE 时才为 TRUE)。步骤 2:NOT FALSE = TRUE。
Inside parentheses first: FALSE OR FALSE = FALSE. Then NOT FALSE = TRUE.先求括号内:FALSE OR FALSE = FALSE。然后 NOT FALSE = TRUE。
Going deeper — Boolean expressions in programming conditions深入 — 编程条件中的布尔表达式

In code, Boolean expressions appear inside if statements and while loops. Compound conditions combine comparison operators with Boolean operators: e.g. if (age >= 16 and has_license). De Morgan's Laws are useful for simplification: NOT (A AND B) = (NOT A) OR (NOT B); NOT (A OR B) = (NOT A) AND (NOT B). These let you rewrite negated compound conditions into a form that is easier to read and test.在代码中,布尔表达式出现在 if 语句和 while 循环中。复合条件将比较运算符与布尔运算符结合:例如 if (age >= 16 and has_license)。德摩根定律对化简很有用:NOT (A AND B) = (NOT A) OR (NOT B);NOT (A OR B) = (NOT A) AND (NOT B)。这些定律使你能够将取反的复合条件改写为更易读、更易测试的形式。


Logic Gates and Truth Tables逻辑门与真值表

A logic gate is a hardware circuit that implements one Boolean operation. Three fundamental gates correspond to the three Boolean operators:逻辑门(logic gate)是实现一个布尔运算的硬件电路。三个基本门对应三个布尔运算符:
  • AND gateAND 门(与门) — two inputs; output is 1 only when both inputs are 1.— 两个输入;只有当两个输入都为 1 时输出为 1。
  • OR gateOR 门(或门) — two inputs; output is 1 when at least one input is 1.— 两个输入;至少一个输入为 1 时输出为 1。
  • NOT gate / inverterNOT 门 / 反相器(非门) — one input; output is the complement (0→1, 1→0).— 一个输入;输出为补(0→1,1→0)。
CSTA 3B-CS-02 (verbatim): "Illustrate ways computing systems implement logic, input, and output through hardware components." Descriptive Statement: "Examples of components could include logic gates and IO pins." CSTA 3A-DA-09 Descriptive Statement explicitly names "logic gates" as a conversion example.CSTA 3B-CS-02(原文):"说明计算系统如何通过硬件组件实现逻辑、输入和输出。"描述性说明:"组件示例包括逻辑门和 IO 引脚。"CSTA 3A-DA-09 描述性说明明确将"逻辑门"列为转换示例。
WE
Worked Example 7 · Combined gate truth table例题 7 · 组合门真值表

Build the truth table for the circuit: Output = (A AND B) OR (NOT A). Use 0/1 notation.为以下电路建立真值表:输出 = (A AND B) OR (NOT A)。使用 0/1 表示法。

ABA AND BNOT AOutput: (A AND B) OR (NOT A)输出:(A AND B) OR (NOT A)
00011
01011
10000
11101

Reading the table: whenever A=0, NOT A=1, so the OR is always 1. When A=1, NOT A=0, so the output equals A AND B = B. The circuit behaves like a conditional: "give me B, but only when A is 1; otherwise output 1."读表:只要 A=0,NOT A=1,则 OR 结果始终为 1。当 A=1 时,NOT A=0,输出等于 A AND B = B。该电路的行为类似于条件:当 A=1 时输出 B,否则输出 1。

How to build any truth table:如何构建任意真值表:

1. List all input combinations (n inputs = 2^n rows).
   2 inputs → 4 rows: 00, 01, 10, 11
   3 inputs → 8 rows: 000, 001, 010, 011, 100, 101, 110, 111

2. Add intermediate columns for each sub-expression.

3. Fill the final output column by evaluating each row.
What is the output of an AND gate when one input is 0 and the other is 1?当 AND 门的一个输入为 0、另一个为 1 时,输出是什么?
§7 · Q1
11
00
Depends on which input is 0取决于哪个输入为 0
Undefined未定义
AND gate output is 1 only when BOTH inputs are 1. If either input is 0, the output is 0. Here one input is 0, so output = 0.AND 门只有当两个输入都为 1 时输出才为 1。如果任一输入为 0,输出为 0。此处一个输入为 0,所以输出 = 0。
AND requires BOTH inputs to be 1 for output=1. One input is 0, so output=0 regardless of which is which.AND 要求两个输入都为 1 才能输出 1。一个输入为 0,所以无论哪个是 0,输出都为 0。
How many rows does the truth table for a 3-input Boolean expression have?一个 3 输入布尔表达式的真值表有多少行?
§7 · Q2
33
66
44
88
n inputs produce 2n rows (all combinations of T/F). 3 inputs: 23 = 8 rows (000, 001, 010, 011, 100, 101, 110, 111).n 个输入产生 2n 行(T/F 的所有组合)。3 个输入:23 = 8 行(000、001、010、011、100、101、110、111)。
Truth table rows = 2n where n = number of inputs. 3 inputs = 23 = 8 rows. 2 inputs = 4 rows; 4 inputs = 16 rows.真值表行数 = 2n,其中 n = 输入数量。3 个输入 = 23 = 8 行。2 个输入 = 4 行;4 个输入 = 16 行。
Going deeper — NAND, NOR, and universal gates深入 — NAND、NOR 与通用门

NAND (NOT AND) and NOR (NOT OR) are each universal gates: any Boolean function can be built from NAND gates alone (or NOR gates alone). This is why real CPUs are built almost entirely from NAND gates — they are cheaper to fabricate in CMOS. NAND truth table: output is 0 only when both inputs are 1 (the complement of AND). XOR (exclusive OR) outputs 1 when exactly one input is 1 (not both) — used in binary addition circuits (the sum bit of a half adder is XOR, the carry bit is AND).NAND(NOT AND)和 NOR(NOT OR)各自都是通用门:任何布尔函数都可以仅用 NAND 门(或仅用 NOR 门)构建。这就是为什么真实 CPU 几乎完全由 NAND 门构成——它们在 CMOS 工艺中制造成本更低。NAND 真值表:只有当两个输入都为 1 时输出才为 0(AND 的补)。XOR(异或)在恰好一个输入为 1(而非两个都是)时输出 1——用于二进制加法电路(半加器的和位是 XOR,进位位是 AND)。


Exam Strategy and Common Pitfalls考试策略与常见陷阱

Number system questions (§1–§4)数制题(§1–§4)
  • Always show the place-value table.始终列出位权表。 For binary-to-decimal, write out the column headers (128, 64, 32, 16, 8, 4, 2, 1) and fill in the bits. Examiners award method marks even when the final answer is wrong.对于二进制转十进制,写出列标题(128、64、32、16、8、4、2、1)并填入位值。即使最终答案错误,考官也会给方法分。
  • Hex ↔ binary: go via nibbles.十六进制 ↔ 二进制:通过半字节转换。 Never convert hex to decimal then to binary. Split hex digits into 4-bit nibbles directly. 0xB3 = 1011 0011, not "179 in decimal first."不要将十六进制先转十进制再转二进制。直接将十六进制位拆成 4 位半字节。0xB3 = 1011 0011,而不是"先转为十进制 179"。
  • Binary addition: track carries explicitly.二进制加法:明确追踪进位。 Write the carry row above the addition. Forgetting to propagate a carry is the most common arithmetic error. Check by converting both operands to decimal, adding, then converting back.在加法上方写出进位行。忘记传播进位是最常见的算术错误。通过将两个操作数转换为十进制相加后再转回来验证。
Text encoding questions (§5)文本编码题(§5)
  • Know the key ASCII anchors.记住关键 ASCII 锚点。 'A'=65, 'a'=97, '0'=48. From these, any letter or digit offset is computable: 'C' = 65+2 = 67; 'z' = 97+25 = 122.'A'=65,'a'=97,'0'=48。从这些锚点出发,任何字母或数字的偏移量都可以计算:'C' = 65+2 = 67;'z' = 97+25 = 122。
  • Unicode ≠ ASCII for non-Latin characters.非拉丁字符中 Unicode ≠ ASCII。 ASCII cannot encode Chinese, Arabic, or emoji. State this explicitly when a question involves non-English text.ASCII 无法编码中文、阿拉伯文或表情符号。当题目涉及非英文文本时,请明确说明这一点。
Boolean logic and gates (§6–§7)布尔逻辑与逻辑门(§6–§7)
  • Build the truth table column by column.逐列构建真值表。 For a compound expression, add one intermediate column per operator. Never try to evaluate the whole expression in your head per row — evaluate sub-expressions first.对于复合表达式,每个运算符增加一个中间列。不要试图在脑子里逐行求整个表达式——先求子表达式。
  • AND vs OR: the decisive test.AND 与 OR 的决定性测试。 AND is FALSE unless all inputs are TRUE. OR is TRUE unless all inputs are FALSE. Test with all-FALSE and all-TRUE inputs first — those two rows distinguish AND from OR immediately.除非所有输入都为 TRUE,否则 AND 为 FALSE。除非所有输入都为 FALSE,否则 OR 为 TRUE。首先用全 FALSE 和全 TRUE 输入测试——这两行能立即区分 AND 和 OR。
  • n inputs = 2n rows.n 个输入 = 2n 行。 Always check that your truth table has the right number of rows before filling it in.在填写真值表之前,始终检查行数是否正确。
Answer hygiene作答规范
  • Use 0 and 1, not T and F, for gate questions.逻辑门题中用 0 和 1,而非 T 和 F。 Hardware and circuit questions conventionally use 0/1. Logical expressions in code use TRUE/FALSE. Use the notation the question uses.硬件和电路题习惯用 0/1。代码中的逻辑表达式用 TRUE/FALSE。使用题目所用的表示法。
  • Verify conversions in both directions.双向验证转换。 After converting decimal 45 to binary 00101101, always verify: 32+8+4+1=45. This 10-second check prevents losing marks on arithmetic slips.将十进制 45 转换为二进制 00101101 后,始终验证:32+8+4+1=45。这个 10 秒检查可防止因算术失误丢分。

Flashcards闪卡

0 / 14 flipped0 / 14 已翻
What is a bit?什么是位(bit)?
A single binary digit: 0 or 1. The smallest unit of digital information. AP CSP DAT-1.A: "Data can be represented using bits."单个二进制位:0 或 1。数字信息的最小单位。AP CSP DAT-1.A:"数据可以用位来表示。"
How many values can n bits represent?n 位可以表示多少个值?
2n values. 1 bit = 2 values; 8 bits = 256 values; 16 bits = 65,536 values. Each additional bit doubles the count.2n 个值。1 位 = 2 个值;8 位 = 256 个值;16 位 = 65,536 个值。每增加一位,数量翻倍。
Binary place values (right to left)二进制位权(从右到左)
1, 2, 4, 8, 16, 32, 64, 128, … Each column is double the one to its right.1、2、4、8、16、32、64、128……每列是其右列的两倍。
Decimal 45 in binary?十进制 45 的二进制是什么?
00101101. Check: 32+8+4+1 = 45. Method: divide repeatedly by 2, read remainders bottom-up.00101101。验证:32+8+4+1 = 45。方法:反复除以 2,从下往上读余数。
Hex digits A–F in decimal十六进制 A–F 的十进制值
A=10, B=11, C=12, D=13, E=14, F=15. One hex digit = 4 bits. Two hex digits = 1 byte.A=10、B=11、C=12、D=13、E=14、F=15。一个十六进制位 = 4 位。两个十六进制位 = 1 字节。
Convert 0xB3 to binary将 0xB3 转换为二进制
B=1011, 3=0011 → 10110011. Group 4 bits per hex digit, left to right.B=1011,3=0011 → 10110011。每个十六进制位对应 4 位,从左到右。
Binary addition: 1 + 1 = ?二进制加法:1 + 1 = ?
10 (write 0, carry 1). Binary has no digit "2" — exceeding 1 causes a carry, just like exceeding 9 causes a carry in decimal.10(写 0,进位 1)。二进制没有数字"2"——超过 1 就会进位,就像十进制超过 9 进位一样。
What is overflow?什么是溢出(overflow)?
When a result needs more bits than are available; the extra leading bits are lost, giving a wrong answer. AP CSP DAT-1.B consequence of fixed-width bit representation.当结果需要的位数超过可用位数时,多余的高位丢失,导致错误答案。AP CSP DAT-1.B:固定宽度位表示的后果。
ASCII: 'A', 'a', '0' valuesASCII:'A'、'a'、'0' 的值
'A' = 65, 'a' = 97, '0' = 48. Lowercase = uppercase + 32. Letters are consecutive (B=66, C=67…).'A' = 65,'a' = 97,'0' = 48。小写 = 大写 + 32。字母连续(B=66、C=67……)。
ASCII vs UnicodeASCII 与 Unicode
ASCII: 7-bit, 128 characters, English only. Unicode: superset of ASCII, 140,000+ characters, every writing system. UTF-8 is backward-compatible with ASCII. ON ICS3U A1.2.ASCII:7 位,128 个字符,仅限英文。Unicode:ASCII 的超集,140,000+ 个字符,涵盖所有书写系统。UTF-8 与 ASCII 向后兼容。ON ICS3U A1.2。
AND operator: truth table summaryAND 运算符(与):真值表总结
TRUE only when BOTH inputs are TRUE. All other cases: FALSE. "Both must be on."只有两个输入都为 TRUE 时才为 TRUE。其他情况均为 FALSE。"两个都必须开启。"
OR operator: truth table summaryOR 运算符(或):真值表总结
FALSE only when BOTH inputs are FALSE. All other cases: TRUE. "At least one must be on."只有两个输入都为 FALSE 时才为 FALSE。其他情况均为 TRUE。"至少一个开启即可。"
NOT operatorNOT 运算符(非)
Flips the input: NOT TRUE = FALSE; NOT FALSE = TRUE. Single input, single output. Inverts the signal.取反:NOT TRUE = FALSE;NOT FALSE = TRUE。单输入、单输出。反转信号。
How many truth table rows for n inputs?n 个输入的真值表有多少行?
2n rows. 2 inputs = 4 rows; 3 inputs = 8 rows; 4 inputs = 16 rows.2n 行。2 个输入 = 4 行;3 个输入 = 8 行;4 个输入 = 16 行。

Practice Quiz综合测验

What is the decimal value of the binary number 11001010?二进制数 11001010 的十进制值是多少?
Q1
194194
186186
200200
202202
Place values for 11001010: 128+64+0+0+8+0+2+0 = 128+64+8+2 = 202.11001010 各位权:128+64+0+0+8+0+2+0 = 128+64+8+2 = 202。
Write out column values (128,64,32,16,8,4,2,1) under each bit: 1,1,0,0,1,0,1,0. Add where bit=1: 128+64+8+2=202.在每位下方写出位权(128、64、32、16、8、4、2、1):1、1、0、0、1、0、1、0。位为 1 处相加:128+64+8+2=202。
What is the hexadecimal representation of binary 10101111?二进制 10101111 的十六进制表示是什么?
Q2
0xBA
0xAF
0xFA
0xAB
Split: 1010 | 1111. Left nibble 1010 = 10 = A. Right nibble 1111 = 15 = F. Result: 0xAF.分组:1010 | 1111。左半字节 1010 = 10 = A。右半字节 1111 = 15 = F。结果:0xAF。
Group 4 bits: 1010=A (=10), 1111=F (=15). So 10101111 = 0xAF, not 0xAB or 0xFA.每 4 位分组:1010=A(=10),1111=F(=15)。所以 10101111 = 0xAF,不是 0xAB 或 0xFA。
What is the result of 0111 + 0101 in binary?二进制 0111 + 0101 的结果是什么?
Q3
1010
1011
1100
1110
7 + 5 = 12. In binary: bit0: 1+1=0 c1; bit1: 1+0+1=0 c1; bit2: 1+1+1=1 c1; bit3: 0+0+1=1. Result: 1100 = 12. ✓7 + 5 = 12。二进制:第 0 位:1+1=0 进 1;第 1 位:1+0+1=0 进 1;第 2 位:1+1+1=1 进 1;第 3 位:0+0+1=1。结果:1100 = 12。✓
0111=7, 0101=5, sum=12=1100. Work right-to-left tracking carries carefully.0111=7,0101=5,和=12=1100。从右到左仔细追踪进位。
The ASCII code for 'Z' is 90. What is the ASCII code for 'z' (lowercase)?字符 'Z' 的 ASCII 码为 90。小写字母 'z' 的 ASCII 码是多少?
Q4
122122
9191
116116
5858
Lowercase = uppercase + 32. 'Z' = 90, so 'z' = 90 + 32 = 122. The same +32 offset applies to all letter pairs A/a through Z/z.小写 = 大写 + 32。'Z' = 90,所以 'z' = 90 + 32 = 122。同样的 +32 偏移量适用于所有字母对 A/a 到 Z/z。
Lowercase letters = uppercase + 32. 'a'=97='A'+32=65+32. So 'z'='Z'+32=90+32=122.小写字母 = 大写 + 32。'a'=97='A'+32=65+32。所以 'z'='Z'+32=90+32=122。
Evaluate: (TRUE OR FALSE) AND (NOT TRUE)求值:(TRUE OR FALSE) AND (NOT TRUE)
Q5
TRUETRUE
FALSEFALSE
Cannot be determined无法确定
TRUE AND FALSETRUE AND FALSE
Step 1: TRUE OR FALSE = TRUE. Step 2: NOT TRUE = FALSE. Step 3: TRUE AND FALSE = FALSE.步骤 1:TRUE OR FALSE = TRUE。步骤 2:NOT TRUE = FALSE。步骤 3:TRUE AND FALSE = FALSE。
Left bracket: TRUE OR FALSE = TRUE. Right: NOT TRUE = FALSE. Then TRUE AND FALSE = FALSE.左括号:TRUE OR FALSE = TRUE。右边:NOT TRUE = FALSE。然后 TRUE AND FALSE = FALSE。
Which CSTA standard names "ASCII/Unicode representation" and "logic gates" as examples of bit representation? 🇺🇸 CSTA哪个 CSTA 标准将"ASCII/Unicode 表示"和"逻辑门"列为位表示的示例?🇺🇸 CSTA
Q6
3B-CS-02
3A-AP-17
3A-DA-09
DAT-1.B
CSTA 3A-DA-09 (verbatim): "Translate between different bit representations of real-world phenomena, such as characters, numbers, and images." Its Descriptive Statement names "ASCII/Unicode representation, and logic gates" explicitly.CSTA 3A-DA-09(原文):"在不同位表示形式(如字符、数字和图像)之间转换。"其描述性说明明确点名"ASCII/Unicode 表示及逻辑门"。
3A-DA-09 is the data-representation standard that names ASCII, Unicode, and logic gates. 3B-CS-02 covers hardware implementation of logic. DAT-1.B is the AP CSP Learning Objective (consequence of bit representation).3A-DA-09 是点名 ASCII、Unicode 和逻辑门的数据表示标准。3B-CS-02 涵盖逻辑的硬件实现。DAT-1.B 是 AP CSP 学习目标(位表示的后果)。
Ontario ICS3U expectation A1.4 requires students to correctly use which operators? 🇨🇦 ON ICS3U安大略 ICS3U 期望 A1.4 要求学生正确使用哪些运算符?🇨🇦 ON ICS3U
Q7
Boolean operators (AND, OR, NOT), comparison operators, and arithmetic operators布尔运算符(AND、OR、NOT)、比较运算符和算术运算符
Only Boolean operators (AND, OR, NOT)仅布尔运算符(AND、OR、NOT)
Only comparison operators仅比较运算符
Bitwise operators only仅位运算符
ICS3U A1.4 (verbatim): "demonstrate the ability to use Boolean operators (e.g., AND, OR, NOT), comparison operators (i.e., equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to), arithmetic operators … and order of operations correctly in computer programs."ICS3U A1.4(原文):"展示在计算机程序中正确使用布尔运算符(如 AND、OR、NOT)、比较运算符(即等于、不等于、大于、小于、大于等于、小于等于)、算术运算符……及运算顺序的能力。"
A1.4 names all three categories: Boolean operators, comparison operators, AND arithmetic operators. See the verbatim expectation text.A1.4 点名三类:布尔运算符、比较运算符和算术运算符。见原文期望文本。

Readiness Checklist准备就绪清单

Tick each item when you can do it cold, without notes, on a first attempt.能在无笔记、首次尝试下完成,再勾选每一项。

0 / 11 mastered已掌握 0 / 11

What This Feeds Into本单元的去向

Binary representation, Boolean logic, and data encoding underpin nearly every other topic in computer science. Control flow uses Boolean expressions in every if-statement and while-loop. Data structures store values using bit-level representations. Networks transmit binary data encoded in bytes. Understanding this unit makes every subsequent unit more legible because you will know what the hardware is actually doing beneath the abstraction layers.二进制表示、布尔逻辑和数据编码几乎支撑着计算机科学中的每个其他主题。控制流在每个 if 语句和 while 循环中使用布尔表达式。数据结构使用位级表示在内存中存储值。网络以字节编码的二进制数据进行传输。理解本单元会使每个后续单元更加清晰,因为你将了解硬件在抽象层之下实际在做什么。

Within High School Computer Science.在 HS Computer Science 内部。

Programming Fundamentals (Unit 2) uses Boolean data types and operators directly in code — the truth tables here give you the exact semantics. Control Flow (Unit 3) builds compound conditions from Boolean operators. Strings and Text Processing (Unit 6) depends on character encoding (ASCII / Unicode) established here. Networks and the Internet (Unit 11) transmits binary data in packets — bytes, bits, and hex addresses are the vocabulary of that unit.编程基础(单元 2)在代码中直接使用布尔数据类型和运算符——这里的真值表给出了确切的语义。控制流(单元 3)从布尔运算符构建复合条件。字符串与文本处理(单元 6)依赖于此处建立的字符编码(ASCII / Unicode)。网络与互联网(单元 11)以数据包传输二进制数据——字节、位和十六进制地址是该单元的词汇。

AP feeder.AP 衔接。

AP CSP Big Idea 2 (Data, 17–22% of the exam) is the direct downstream assessment of §1–§5. Learning Objectives DAT-1.A and DAT-1.B are the exam anchors. AP CSA (Java) uses boolean as a primitive type with operators &&, ||, ! — the same AND/OR/NOT under Java syntax. Fluency with truth tables from this guide transfers directly to AP CSA boolean expression questions.AP CSP 大概念 2(数据,占考试 17–22%)是 §1–§5 的直接下游评估。学习目标 DAT-1.A 和 DAT-1.B 是考试锚点。AP CSA(Java)将 boolean 用作原始类型,运算符为 &&||!——即 Java 语法下的 AND/OR/NOT。本指南的真值表熟练度直接迁移到 AP CSA 布尔表达式题目。