More integer encoding, git objects, floor/ceiling.
parent
1651c9d6c3
commit
cdb916c2b4
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"collapse-filter": false,
|
||||||
|
"search": "",
|
||||||
|
"showTags": false,
|
||||||
|
"showAttachments": false,
|
||||||
|
"hideUnresolved": false,
|
||||||
|
"showOrphans": true,
|
||||||
|
"collapse-color-groups": false,
|
||||||
|
"colorGroups": [],
|
||||||
|
"collapse-display": false,
|
||||||
|
"showArrow": false,
|
||||||
|
"textFadeMultiplier": 0,
|
||||||
|
"nodeSizeMultiplier": 1,
|
||||||
|
"lineSizeMultiplier": 1,
|
||||||
|
"collapse-forces": false,
|
||||||
|
"centerStrength": 0.518713248970312,
|
||||||
|
"repelStrength": 10,
|
||||||
|
"linkStrength": 1,
|
||||||
|
"linkDistance": 250,
|
||||||
|
"scale": 0.2962962962962963,
|
||||||
|
"close": false
|
||||||
|
}
|
|
@ -91,7 +91,11 @@
|
||||||
"ordering-n-repetition-n.jpg",
|
"ordering-n-repetition-n.jpg",
|
||||||
"triangular-gnomon.png",
|
"triangular-gnomon.png",
|
||||||
"pascals-triangle.webp",
|
"pascals-triangle.webp",
|
||||||
"square-gnomon.png"
|
"square-gnomon.png",
|
||||||
|
"floor-negative.png",
|
||||||
|
"floor-positive.png",
|
||||||
|
"ceil-positive.png",
|
||||||
|
"ceil-negative.png"
|
||||||
],
|
],
|
||||||
"File Hashes": {
|
"File Hashes": {
|
||||||
"algorithms/index.md": "cd7c7ba91fb2f961c9f2437777e8e2ac",
|
"algorithms/index.md": "cd7c7ba91fb2f961c9f2437777e8e2ac",
|
||||||
|
@ -119,7 +123,7 @@
|
||||||
"posix/index.md": "97b1b8ecb9a953e855a9acf0ab25b8c8",
|
"posix/index.md": "97b1b8ecb9a953e855a9acf0ab25b8c8",
|
||||||
"posix/signals.md": "e8a62cbece8a6bfc54a4e67bbdf3be7c",
|
"posix/signals.md": "e8a62cbece8a6bfc54a4e67bbdf3be7c",
|
||||||
"templates/daily.md": "7866014e730e85683155207a02e367d8",
|
"templates/daily.md": "7866014e730e85683155207a02e367d8",
|
||||||
"posix/regexp.md": "f5fb177c7356faf1bf768023c2563c54",
|
"posix/regexp.md": "eb1e686756c283a60a7213d3ed39e78b",
|
||||||
"journal/2024-02-04.md": "e2b5678fc53d7284b71ed6820c02b954",
|
"journal/2024-02-04.md": "e2b5678fc53d7284b71ed6820c02b954",
|
||||||
"gawk/regexp.md": "d9229f1eabe1b99e965eecaa03bee86c",
|
"gawk/regexp.md": "d9229f1eabe1b99e965eecaa03bee86c",
|
||||||
"_templates/daily.md": "5863e4524f8d012e153918d238c611a4",
|
"_templates/daily.md": "5863e4524f8d012e153918d238c611a4",
|
||||||
|
@ -178,7 +182,7 @@
|
||||||
"_journal/2024-02/2024-02-14.md": "aa009f9569e175a8104b0537ebcc5520",
|
"_journal/2024-02/2024-02-14.md": "aa009f9569e175a8104b0537ebcc5520",
|
||||||
"_journal/2024-02-16.md": "5cc129254afd553829be3364facd23db",
|
"_journal/2024-02-16.md": "5cc129254afd553829be3364facd23db",
|
||||||
"_journal/2024-02/2024-02-15.md": "16cb7563d404cb543719b7bb5037aeed",
|
"_journal/2024-02/2024-02-15.md": "16cb7563d404cb543719b7bb5037aeed",
|
||||||
"algebra/floor-ceiling.md": "828b11e642d6803a740b58f27ff047cf",
|
"algebra/floor-ceiling.md": "556406772daaa415d546b1a8bf41b5dd",
|
||||||
"algebra/index.md": "90b842eb694938d87c7c68779a5cacd1",
|
"algebra/index.md": "90b842eb694938d87c7c68779a5cacd1",
|
||||||
"algorithms/binary-search.md": "27189885f0bc1e8b8b9049da3ed92f98",
|
"algorithms/binary-search.md": "27189885f0bc1e8b8b9049da3ed92f98",
|
||||||
"_journal/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
"_journal/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
||||||
|
@ -220,15 +224,15 @@
|
||||||
"_journal/2024-02/2024-02-27.md": "f75a0d04a875aeee932343dae0c78768",
|
"_journal/2024-02/2024-02-27.md": "f75a0d04a875aeee932343dae0c78768",
|
||||||
"filesystems/index.md": "cbd2b0290a3ba3b32abec4bd8bfefad5",
|
"filesystems/index.md": "cbd2b0290a3ba3b32abec4bd8bfefad5",
|
||||||
"filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa",
|
"filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa",
|
||||||
"git/objects.md": "1c867853b080700a73de55b7be185f8d",
|
"git/objects.md": "e9b98576291ca04496c2f0863f526cfa",
|
||||||
"git/index.md": "83d2d95fc549d9e8436946c7bd058d15",
|
"git/index.md": "83d2d95fc549d9e8436946c7bd058d15",
|
||||||
"encoding/integer.md": "052dce2f39b72cc8d46bea58bfdb1b97",
|
"encoding/integer.md": "e15129fc5ae9a8348c57c2d533feda41",
|
||||||
"_journal/2024-02-29.md": "f610f3caed659c1de3eed5f226cab508",
|
"_journal/2024-02-29.md": "f610f3caed659c1de3eed5f226cab508",
|
||||||
"_journal/2024-02/2024-02-28.md": "7489377c014a2ff3c535d581961b5b82",
|
"_journal/2024-02/2024-02-28.md": "7489377c014a2ff3c535d581961b5b82",
|
||||||
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
|
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
|
||||||
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
|
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
|
||||||
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
|
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
|
||||||
"algebra/sequences/index.md": "e5a7cdfbcb61709ce2963c4b5e53a8f2",
|
"algebra/sequences/index.md": "d668df1467c7cc70691aeb1d9b17e39d",
|
||||||
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
|
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
|
||||||
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
|
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
|
||||||
"algebra/sequences/triangular-numbers.md": "c6626d8aa86776b6ce794c3551862d5a",
|
"algebra/sequences/triangular-numbers.md": "c6626d8aa86776b6ce794c3551862d5a",
|
||||||
|
@ -242,7 +246,11 @@
|
||||||
"algebra/sequences/geometric.md": "53936ec392b3b714bd4a9bdb4554b582",
|
"algebra/sequences/geometric.md": "53936ec392b3b714bd4a9bdb4554b582",
|
||||||
"algebra/sequences/arithmetic.md": "80381ca0f2b3b9a1c155c597a7dea75a",
|
"algebra/sequences/arithmetic.md": "80381ca0f2b3b9a1c155c597a7dea75a",
|
||||||
"_journal/2024-03-06.md": "ac7a3d764934f49b2be7aa76e402d853",
|
"_journal/2024-03-06.md": "ac7a3d764934f49b2be7aa76e402d853",
|
||||||
"_journal/2024-03/2024-03-05.md": "94b28d0b9bc62cc0bd99d315fb7c6d30"
|
"_journal/2024-03/2024-03-05.md": "94b28d0b9bc62cc0bd99d315fb7c6d30",
|
||||||
|
"_journal/2024-03-07.md": "7bf68d6d81e89aa00f5ddd7510b69e3e",
|
||||||
|
"_journal/2024-03/2024-03-06.md": "c1d8b6b0d3c5ad34b8135230ec102443",
|
||||||
|
"_journal/2024-03-08.md": "07b6c200dcdc7116e1209c7ba6a01613",
|
||||||
|
"_journal/2024-03/2024-03-07.md": "58b84cabda4e875ab0c9e5317b2b6e2c"
|
||||||
},
|
},
|
||||||
"fields_dict": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
---
|
---
|
||||||
title: "2024-03-06"
|
title: "2024-03-08"
|
||||||
---
|
---
|
||||||
|
|
||||||
- [x] Anki Flashcards
|
- [x] Anki Flashcards
|
||||||
- [x] KoL
|
- [x] KoL
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
||||||
- [ ] Go (1 Life & Death Problem)
|
- [x] Go (1 Life & Death Problem)
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
||||||
- [ ] Interview Prep (1 Practice Problem)
|
- [ ] Interview Prep (1 Practice Problem)
|
||||||
- [ ] Log Work Hours (Max 3 hours)
|
- [ ] Log Work Hours (Max 3 hours)
|
||||||
|
|
||||||
* Added notes on how asymptotic notation relates to one another.
|
* 101weiqi (serial numbers)
|
||||||
|
* Q-8118
|
||||||
|
* Q-56273
|
||||||
|
* Q-220867
|
||||||
|
* Q-141879
|
||||||
|
* Q-12638
|
||||||
|
* Q-242062
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
title: "2024-03-06"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [x] Go (1 Life & Death Problem)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
||||||
|
- [x] Interview Prep (1 Practice Problem)
|
||||||
|
- [x] Log Work Hours (Max 3 hours)
|
||||||
|
|
||||||
|
* Added notes on how asymptotic notation relates to one another.
|
||||||
|
* Leetcode Problems
|
||||||
|
* [Search In Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)
|
||||||
|
* [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)
|
||||||
|
* [Search Input Position](https://leetcode.com/problems/search-insert-position/)
|
||||||
|
* [Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)
|
||||||
|
* 101weiqi (serial numbers)
|
||||||
|
* Q-151618
|
||||||
|
* Q-20227
|
||||||
|
* Q-215640
|
||||||
|
* Began reading chapter 3 of "Designing Data-Intensive Applications". Up to and including in-memory hash indices.
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: "2024-03-07"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [ ] Go (1 Life & Death Problem)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
||||||
|
- [x] Interview Prep (1 Practice Problem)
|
||||||
|
- [ ] Log Work Hours (Max 3 hours)
|
||||||
|
|
||||||
|
* Spent a while thinking through floor/ceiling identities. Want to return to two's-complement division (rounding up) after I dive into the division algorithm more.
|
||||||
|
* In particular, I want to explore the relationship between floors and `mq + r` as well as ceilings and `mq - r`.
|
||||||
|
* Read chapter 3 of "Designing Data-Intensive Applications".
|
||||||
|
* Transcribed hard-copy soft skills notes to Google document.
|
||||||
|
* Leetcode Problems
|
||||||
|
* [Count and Say](https://leetcode.com/problems/count-and-say/)
|
||||||
|
* [Combination Sum](https://leetcode.com/problems/combination-sum/)
|
||||||
|
* [Multiply Strings](https://leetcode.com/problems/multiply-strings/)
|
|
@ -60,7 +60,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What does $\lceil x \rceil - \lfloor x \rceil$ equal?
|
What does $\lceil x \rceil - \lfloor x \rfloor$ equal?
|
||||||
Back: Either $0$ or $1$.
|
Back: Either $0$ or $1$.
|
||||||
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
<!--ID: 1708110779681-->
|
<!--ID: 1708110779681-->
|
||||||
|
@ -69,7 +69,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What can be said about $x$ if $\lceil x \rceil - \lfloor x \rfloor = 0$?
|
What can be said about $x$ if $\lceil x \rceil - \lfloor x \rfloor = 0$?
|
||||||
Back: $x$ is even.
|
Back: $x$ is an integer.
|
||||||
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
<!--ID: 1708110779687-->
|
<!--ID: 1708110779687-->
|
||||||
END%%
|
END%%
|
||||||
|
@ -77,11 +77,51 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What can be said about $x$ if $\lceil x \rceil - \lfloor x \rfloor = 1$?
|
What can be said about $x$ if $\lceil x \rceil - \lfloor x \rfloor = 1$?
|
||||||
Back: $x$ is odd.
|
Back: $x$ is not an integer.
|
||||||
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
<!--ID: 1708110779693-->
|
<!--ID: 1708110779693-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What values of $x$ satisfy $\lfloor x \rfloor = \lceil x \rceil - 1$?
|
||||||
|
Back: Non-integral values.
|
||||||
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
|
<!--ID: 1709831032489-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What values of $x$ satisfy $\lceil x \rceil = \lfloor x \rfloor + 1$?
|
||||||
|
Back: Non-integral values.
|
||||||
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
|
<!--ID: 1709831032496-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What values of $x$ satisfy $\lfloor x \rfloor = \lceil x \rceil + 1$?
|
||||||
|
Back: None.
|
||||||
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
|
<!--ID: 1709831032505-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What values of $x$ satisfy $\lceil x \rceil = \lfloor x \rfloor - 1$?
|
||||||
|
Back: None.
|
||||||
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
|
<!--ID: 1709831032513-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
For what values $k$ is horizontal and vertical shifting of $\lfloor x \rfloor$ the same?
|
||||||
|
Back: Integral values.
|
||||||
|
Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
|
<!--ID: 1709831032519-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What C operator corresponds to floor division?
|
What C operator corresponds to floor division?
|
||||||
|
@ -90,6 +130,14 @@ Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete M
|
||||||
<!--ID: 1708110779699-->
|
<!--ID: 1708110779699-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What C operator corresponds to integer division?
|
||||||
|
Back: `/`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032524-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
When does C operator `/` behave like floor division?
|
When does C operator `/` behave like floor division?
|
||||||
|
@ -306,5 +354,6 @@ END%%
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
* Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
* Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||||
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
|
@ -29,7 +29,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
How is sequence $a_1, a_2, \ldots$ denoted?
|
How is sequence $a_1, a_2, \ldots$ more compactly denoted?
|
||||||
Back: $(a_n)_{n \geq 1}$
|
Back: $(a_n)_{n \geq 1}$
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
<!--ID: 1709302343201-->
|
<!--ID: 1709302343201-->
|
||||||
|
|
|
@ -940,7 +940,7 @@ Addition of two unsigned or two two's-complement numbers operate in much the sam
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
*Why* is adding $w$-bit integral types equal to $w$-bit truncation?
|
*Why* is addition overflow of $w$-bit integral types equivalent to $w$-bit truncation?
|
||||||
Back: The underlying bit adder discards any final carry bit.
|
Back: The underlying bit adder discards any final carry bit.
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1708799678721-->
|
<!--ID: 1708799678721-->
|
||||||
|
@ -1648,7 +1648,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
How is `unsigned x` equivalently modified without using multiplication?
|
How is `unsigned x` equivalently modified using bitwise operations?
|
||||||
```c
|
```c
|
||||||
x = x * pow(2, k);
|
x = x * pow(2, k);
|
||||||
```
|
```
|
||||||
|
@ -1661,6 +1661,21 @@ Tags: c17
|
||||||
<!--ID: 1709570428818-->
|
<!--ID: 1709570428818-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is `unsigned x` equivalently modified using arithmetic operations?
|
||||||
|
```c
|
||||||
|
x = (x << k);
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = x * pow(2, k);
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032382-->
|
||||||
|
END%%
|
||||||
|
|
||||||
Similarly, two's-complement multiplication is defined as follows: $$x *_w^t y = U2T_w((x \cdot y) \bmod 2^w)$$
|
Similarly, two's-complement multiplication is defined as follows: $$x *_w^t y = U2T_w((x \cdot y) \bmod 2^w)$$
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
|
@ -1771,7 +1786,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Assuming two's-complement encoding, how is `int x` equivalently modified without using multiplication?
|
In two's-complement, how is `x` equivalently modified using bitwise operators?
|
||||||
```c
|
```c
|
||||||
x = x * pow(2, k);
|
x = x * pow(2, k);
|
||||||
```
|
```
|
||||||
|
@ -1784,6 +1799,21 @@ Tags: c17
|
||||||
<!--ID: 1709570428828-->
|
<!--ID: 1709570428828-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In two's-complement, how is `x` equivalently modified using arithmetic operations?
|
||||||
|
```c
|
||||||
|
x = (x << k);
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = x * pow(2, k);
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032386-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
How can we rewrite $x \cdot 1101_2$ as an expression of *only* `<<` and `+`?
|
How can we rewrite $x \cdot 1101_2$ as an expression of *only* `<<` and `+`?
|
||||||
|
@ -1837,7 +1867,171 @@ END%%
|
||||||
|
|
||||||
### Division
|
### Division
|
||||||
|
|
||||||
|
Integer division divides the result and discards any fractional result. This has the same effect as rounding toward zero.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is integer division?
|
||||||
|
Back: Division of two numbers that returns the integer part of the result.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032392-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
Integer division $x / y$ is $\lfloor x / y \rfloor$ when $x \geq 0$ and {1:$y > 0$} or $x \leq 0$ and {1:$y < 0$}.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032396-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
Integer division $x / y$ is $\lceil x / y \rceil$ when $x \geq 0$ and {1:$y < 0$} or $x \leq 0$ and {1:$y > 0$}.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032399-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What distinguishes integer division from floor division?
|
||||||
|
Back: The latter does not round towards $0$ with negative results.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032402-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What distinguishes integer division from ceiling division?
|
||||||
|
Back: The latter does not round towards $0$ with positive results.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032406-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
Integer division is often called "truncation {toward zero}".
|
||||||
|
Reference: dirkgently, “Answer to ‘What Is the Behavior of Integer Division?,’” _Stack Overflow_, August 30, 2010, [https://stackoverflow.com/a/3602857](https://stackoverflow.com/a/3602857).
|
||||||
|
<!--ID: 1709831032412-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
Unsigned division is to {logical} right shifts. Two's-complement division is to {arithmetic} right shifts.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032417-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the result of logical right-shifting unsigned $x$ by $k$ bits?
|
||||||
|
Back: $\lfloor x / 2^k \rfloor$
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032421-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In unsigned encoding, *why* is floor a part of expression $x \mathop{\texttt{>>}} k = \lfloor x / 2^k \rfloor$?
|
||||||
|
Back: Because the least significant bit, which may have value `1`, is dropped.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032424-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In unsigned encoding, how is `x` equivalently modified using bitwise operators?
|
||||||
|
```c
|
||||||
|
x = floor(x / pow(2, k));
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = (x >> k);
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032428-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In unsigned encoding, how is `x` equivalently modified using arithmetic operations?
|
||||||
|
```c
|
||||||
|
x = (x >> k);
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = floor(x / pow(2, k));
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032432-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the result of arithmetic right-shifting two's-complement $x$ by $k$ bits?
|
||||||
|
Back: $\lfloor x / 2^k \rfloor$
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1709831032435-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In two's-complement, *why* is floor a part of expression $x \mathop{\texttt{>>}} k = \lfloor x / 2^k \rfloor$?
|
||||||
|
Back: Because the least significant bit, which may have value `1`, is dropped.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032440-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In two's-complement, what is `-1 >> 1`?
|
||||||
|
Back: `-1`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032444-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why is division by a power of two using arithmetic right-shift `x >> k` considered incorrect?
|
||||||
|
Back: This right shift performs floor division, not integer division.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032449-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In two's-complement, how is `x` equivalently modified using bitwise operators?
|
||||||
|
```c
|
||||||
|
x = floor(x / pow(2, k));
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = (x >> k);
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032455-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In two's-complement, how is `x` equivalently modified using arithmetic operations?
|
||||||
|
```c
|
||||||
|
x = (x >> k);
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
x = floor(x / pow(2, k));
|
||||||
|
```
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
Tags: c17
|
||||||
|
<!--ID: 1709831032461-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Cloze
|
Cloze
|
||||||
Interpreted as a key-value store, {oids} are to keys as {objects} are to values.
|
When interpreting git as a key-value store, {oids} are to keys as {objects} are to values.
|
||||||
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
||||||
Tags: fs::cas
|
Tags: fs::cas
|
||||||
<!--ID: 1709177255607-->
|
<!--ID: 1709177255607-->
|
||||||
|
@ -118,7 +118,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Cloze
|
Cloze
|
||||||
The {object database} refers to the {`.git/objects`} directory.
|
The term "{object database}" refers to the {`.git/objects`} directory.
|
||||||
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
||||||
<!--ID: 1709177255644-->
|
<!--ID: 1709177255644-->
|
||||||
END%%
|
END%%
|
||||||
|
@ -240,7 +240,7 @@ What is the decompressed text of the blob generated by the following?
|
||||||
```bash
|
```bash
|
||||||
$ echo -n "abcd" | git hash-object -w --stdin
|
$ echo -n "abcd" | git hash-object -w --stdin
|
||||||
```
|
```
|
||||||
Back: `blob 4\0abcd`
|
Back: `blob 4<NUL>abcd`
|
||||||
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
Reference: Scott Chacon, *Pro Git*, Second edition, The Expert’s Voice in Software Development (New York, NY: Apress, 2014).
|
||||||
<!--ID: 1709345254733-->
|
<!--ID: 1709345254733-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -281,20 +281,20 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
|
||||||
<!--ID: 1707050923724-->
|
<!--ID: 1707050923724-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
Class | Similar To | Meaning
|
| Class | Similar To | Meaning |
|
||||||
------------ | --------------- | ------------------------------------------------
|
| ------------ | --------------- | ------------------------------------------------ |
|
||||||
`[:alnum:]` | `[A-Za-z0-9]` | Alphanumeric characters
|
| `[:alnum:]` | `[A-Za-z0-9]` | Alphanumeric characters |
|
||||||
`[:alpha:]` | `[A-Za-z]` | Alphabetic characters
|
| `[:alpha:]` | `[A-Za-z]` | Alphabetic characters |
|
||||||
`[:blank:]` | `[ \t]` | `' '` and `TAB` characters
|
| `[:blank:]` | `[ \t]` | `' '` and `TAB` characters |
|
||||||
`[:cntrl:]` | | Control characters
|
| `[:cntrl:]` | | Control characters |
|
||||||
`[:digit:]` | `[0-9]` | Numeric characters
|
| `[:digit:]` | `[0-9]` | Numeric characters |
|
||||||
`[:graph:]` | `[^ [:cntrl:]]` | Printable and visible characters
|
| `[:graph:]` | `[^ [:cntrl:]]` | Printable and visible characters |
|
||||||
`[:lower:]` | `[a-z]` | Lowercase alphabetic characters
|
| `[:lower:]` | `[a-z]` | Lowercase alphabetic characters |
|
||||||
`[:print:]` | `[ [:graph:]]` | Printable characters
|
| `[:print:]` | `[ [:graph:]]` | Printable characters |
|
||||||
`[:punct:]` | | All graphic characters except letters and digits
|
| `[:punct:]` | | All graphic characters except letters and digits |
|
||||||
`[:space:]` | `[ \t\n\r\f\v]` | Whitespace characters
|
| `[:space:]` | `[ \t\n\r\f\v]` | Whitespace characters |
|
||||||
`[:upper:]` | `[A-Z]` | Uppercase alphabetic characters
|
| `[:upper:]` | `[A-Z]` | Uppercase alphabetic characters |
|
||||||
`[:xdigit:]` | `[0-9A-Fa-f]` | [[radices#Hexadecimal\|Hexadecimal]] digits
|
| `[:xdigit:]` | `[0-9A-Fa-f]` | [[radices#Hexadecimal\|Hexadecimal]] digits |
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
|
|
Loading…
Reference in New Issue