diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index b997957..33c5b9a 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -171,7 +171,7 @@ "algorithms/binary-search.md": "08cb6dc2dfb204a665d8e8333def20ca", "_journal/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048", "_journal/2024-02/2024-02-16.md": "e701902e369ec53098fc2deed4ec14fd", - "binary/integer-encoding.md": "fc9e88adabcbbf106c50718016e238c7", + "binary/integer-encoding.md": "193566bf1b9e88257002d32bb2bc0bf2", "combinatorics/index.md": "f9de9671fdb6068ef2bb5e63051734be", "_journal/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629", "_journal/2024-02/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048", diff --git a/notes/binary/integer-encoding.md b/notes/binary/integer-encoding.md index 72b6e71..9cac23b 100644 --- a/notes/binary/integer-encoding.md +++ b/notes/binary/integer-encoding.md @@ -108,21 +108,9 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% -%%ANKI -Basic -What does $TMin_w$ evaluate to? -Back: $-2^{w-1}$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% +### Unsigned Encoding -%%ANKI -Basic -What does $TMax_w$ evaluate to? -Back: $2^{w-1} - 1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% +Always represents nonnegative numbers. Given an integral type $\vec{x}$ of $w$ bits, we convert binary to its unsigned encoding with: $$B2U_w(\vec{x}) = \sum_{i=0}^{w-1} 2^ix_i$$ %%ANKI Basic @@ -140,29 +128,9 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% -### Unsigned Encoding - -Always represents nonnegative numbers. Given an integral type $\vec{x}$ of $w$ bits, we convert binary to its unsigned encoding with: $$B2U_w(\vec{x}) = \sum_{i=0}^{w-1} 2^ix_i$$ - %%ANKI Basic -What is the largest unsigned value an integral type of $w$ bits can encode? -Back: $2^w - 1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -What is the smallest unsigned value an integral type of $w$ bits can encode? -Back: $0$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -What half-open interval represents the possible $w$-bit unsigned values? +What half-open interval represents the possible $w$-bit unsigned decimal values? Back: $[0, 2^w)$ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. @@ -186,7 +154,7 @@ END%% %%ANKI Basic -What is the decimal expansion of unsigned type $1010_2$? +What is the decimal expansion of unsigned integer $1010_2$? Back: $2^3 + 2^1 = 10$ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. @@ -302,23 +270,23 @@ Represents negative numbers along with nonnegative ones. Given an integral type %%ANKI Basic -What is the largest two's-complement value an integral type of $w$ bits can encode? -Back: $2^{w-1} - 1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -What is the smallest two's-complement value an integral type of $w$ bits can encode? +What does $TMin_w$ evaluate to? Back: $-2^{w-1}$ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - + END%% %%ANKI Basic -What half-open interval represents the possible $w$-bit two's-complement values? +What does $TMax_w$ evaluate to? +Back: $2^{w-1} - 1$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +What half-open interval represents the possible $w$-bit two's-complement decimal values? Back: $[-2^{w-1}, 2^{w-1})$ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. @@ -507,7 +475,7 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% -The "two's-complement" of an integer often refers to the binary representation of the integer's additive inverse. For example, $0110_2 = 6$ has two's-complement $1010_2 = -6$. In contrast, the "complement" of an integer is the other integer such that together add up to $2^{w-1}$. For example, $0110_2 = 6$ has complement $0010_2 = 2$ (with respect to $2^3 = 8$). +The "two's-complement" of an integer often refers to the binary representation of the integer's additive inverse. For example, $0110_2 = 6$ has two's-complement $1010_2 = -6$. In contrast, the "complement" of a nonnegative integer is the other nonnegative integer such that together add up to $2^{w-1}$. For example, $0110_2 = 6$ has complement $0010_2 = 2$ (with respect to $2^3 = 8$). %%ANKI Basic @@ -517,14 +485,6 @@ Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://e END%% -%%ANKI -Basic -In two's-complement, how many negative values can be encoded compared to nonnegative values? -Back: The same amount. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - %%ANKI Cloze In two's-complement, the {sign bit} partitions the encoding range into two sets. @@ -556,6 +516,12 @@ Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://e END%% +%%ANKI +Cloze +$TMin$ is called the "{weird number}" because {it is it's own two's-complement}. +Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561). +END%% + %%ANKI Basic What is the result of applying the two's-complement operation on $TMin$?