More on printf.
parent
07097ccc7b
commit
4a4c1a30da
|
@ -119,12 +119,12 @@
|
|||
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
|
||||
"algorithms/loop-invariant.md": "d883dfc997ee28a7a1e24b995377792b",
|
||||
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
|
||||
"algorithms/order-growth.md": "ac89d74204040a7c9b870e865c62aa59",
|
||||
"algorithms/order-growth.md": "5fb2e3ccfc3710be7396a37da7c4f162",
|
||||
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
|
||||
"algorithms/sorting/selection-sort.md": "73a077a726afd376650d1bd9e2d0bed9",
|
||||
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
||||
"binary/hexadecimal.md": "033246347c06b6911ea497ce6da25263",
|
||||
"binary/index.md": "4c12fdcd93422987d499cd193737b4c1",
|
||||
"binary/hexadecimal.md": "c3d485f1fd869fe600334ecbef7d5d70",
|
||||
"binary/index.md": "27bdd4423e323cd961ddb307ab28d977",
|
||||
"_journal/2024-02-09.md": "a798d35f0b2bd1da130f7ac766166109",
|
||||
"c/types.md": "cf3e66e5aee58a94db3fdf0783908555",
|
||||
"logic/quantification.md": "37655276de8da531ca2b12706a639224",
|
||||
|
@ -149,13 +149,15 @@
|
|||
"_journal/2024-02/2024-02-11.md": "afee9f502b61e17de231cf2f824fbb32",
|
||||
"encoding/ascii.md": "c01e50f96d0493d94dc4d520c0b6bb71",
|
||||
"encoding/index.md": "071cfa6a5152efeda127b684f420d438",
|
||||
"c/strings.md": "1956bbfd6af40655f945621e4c14fd43",
|
||||
"c/strings.md": "e08be6bdc820ec4903480a736448a5d7",
|
||||
"logic/truth-tables.md": "7892ceaa416c9a65acc79ca1e6ff778f",
|
||||
"logic/short-circuit.md": "26d300f407f14883022d0ef8dc4f7300",
|
||||
"logic/boolean-algebra.md": "c5d699d407e03d280aa1f201bc3e8b02",
|
||||
"_journal/2024-02-13.md": "6242ed4fecabf95df6b45d892fee8eb0",
|
||||
"_journal/2024-02/2024-02-12.md": "618c0035a69b48227119379236a02f44",
|
||||
"binary/shifts.md": "24a1f56268fdbae4fe22e92c18366abc"
|
||||
"binary/shifts.md": "24a1f56268fdbae4fe22e92c18366abc",
|
||||
"_journal/2024-02-14.md": "22dbfc7f440d63a3c5685a3d32ab9c72",
|
||||
"_journal/2024-02/2024-02-13.md": "6242ed4fecabf95df6b45d892fee8eb0"
|
||||
},
|
||||
"fields_dict": {
|
||||
"Basic": [
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: "2024-02-14"
|
||||
---
|
||||
|
||||
- [x] Anki Flashcards
|
||||
- [x] KoL
|
||||
- [ ] Sheet Music (10 min.)
|
||||
- [ ] OGS (1 Life & Death Problem)
|
||||
- [x] Korean (Read 1 Story)
|
||||
- [ ] Interview Prep (1 Practice Problem)
|
||||
- [x] Log Work Hours (Max 3 hours)
|
||||
|
||||
* More flashcards on `printf`. This time on flags.
|
||||
* Read 금덩이를 버린 형제 (Two brothers Who Threw Away Their Lumps of Gold).
|
||||
* Flashcards are growing much more rapidly with my Obsidian_to_Anki plugin approach. Increased new card limit to 40 and will evaluate how well that works.
|
|
@ -13,7 +13,7 @@ The **running time** of an algorithm is usually considered as a function of its
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the running time of a program traditionally measured?
|
||||
How is the running time of a program measured as a function?
|
||||
Back: As a function of its input size.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1707334419352-->
|
||||
|
|
|
@ -57,7 +57,7 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
*When* should padding be introduced on converting binary to hexadecimal?
|
||||
*When* should padding be introduced in binary to hexadecimal conversion?
|
||||
Back: When the number of bits is not a multiple of `4`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707432641571-->
|
||||
|
@ -65,7 +65,7 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Where* is padding introduced on binary to hexadecimal conversion?
|
||||
*Where* is padding introduced in binary to hexadecimal conversion?
|
||||
Back: To the left of the binary sequence.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707432641573-->
|
||||
|
@ -81,7 +81,7 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
What are the possible values the first nibble of $2^n$ can take on?
|
||||
What are the possible values in binary that the first nibble of $2^n$ can take on?
|
||||
Back: `0001`, `0010`, `0100`, and `1000`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707432641580-->
|
||||
|
@ -90,7 +90,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
How is $j$ interpreted in the hex representation of $2^{i + 4j}$?
|
||||
As the number of `0`s in the encoding.
|
||||
Back: As the number of `0`s in the encoding.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707432641582-->
|
||||
END%%
|
||||
|
@ -151,6 +151,14 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1707432641595-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
When does repeated division in decimal to hex conversion end?
|
||||
Back: When the quotient (*not* the remainder) is `0`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707919792632-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is e.g. `0xAC32` expressed as a sum of decimal values?
|
||||
|
|
|
@ -38,7 +38,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
Why does converting from e.g. decimal to another base involve repeated division?
|
||||
Back: The position of a digit corresponds to the base raised to the position.
|
||||
Back: The position of a digit corresponds to the base raised to that position.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1707432641592-->
|
||||
END%%
|
|
@ -44,7 +44,98 @@ END%%
|
|||
|
||||
## `printf`
|
||||
|
||||
The syntax for the format placeholder is `%[param][flags][width][.precision][length]specifier`.
|
||||
The syntax for the format placeholder is `%[flags][width][.precision][length]specifier`.
|
||||
|
||||
Flag | Description
|
||||
--------- | -----------
|
||||
`-` | Left-aligns the output
|
||||
`+` | Prepends a plus for positive signed-numeric types
|
||||
`␣` | Prepends a space for positive signed-numeric types
|
||||
`0` | Prepends zeros for numeric types
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
The {`-`} flag {left-aligns the output}.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756812-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
The `-` flag overrides what default behavior?
|
||||
Back: Output is right-aligned by default.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756840-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
The {`+`} flag {prepends a plus for positive signed-numeric types}.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756846-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
The `+` flag overrides what default behavior?
|
||||
Back: Nothing is prepended to positive signed-numeric types by default.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756852-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
The {`␣`} flag {prepends a space for positive signed-numeric types}.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756856-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
The `␣` flag overrides what default behavior?
|
||||
Back: Nothing is prepended to positive signed-numeric types by default.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756861-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How do the `+` and `␣` flags relate to one another?
|
||||
Back: Both prepend a character to positive signed-numeric types.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756865-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What happens if both the `+` and `␣` flags are specified?
|
||||
Back: The `+` flag takes precedence.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756870-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
The {`0`} flag {prepends zeros for numeric types}.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756875-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What option must be specified for the `0` flag to take effect?
|
||||
Back: The "width" option.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756881-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
The `0` flag overrides what default behavior?
|
||||
Back: Spaces are used to match the "width" option by default.
|
||||
Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962).
|
||||
<!--ID: 1707918756888-->
|
||||
END%%
|
||||
|
||||
Specifier | Description
|
||||
--------- | -----------
|
||||
|
|
Loading…
Reference in New Issue