C literals.

main
Joshua Potter 2024-08-17 18:05:16 -06:00
parent 9ed6b4c9a4
commit 52dfd5b020
4 changed files with 263 additions and 38 deletions

View File

@ -173,7 +173,12 @@
"venn-diagram-abs-comp.png", "venn-diagram-abs-comp.png",
"venn-diagram-intersection.png", "venn-diagram-intersection.png",
"venn-diagram-rel-comp.png", "venn-diagram-rel-comp.png",
"venn-diagram-symm-diff.png" "venn-diagram-symm-diff.png",
"function-bijective.png",
"function-injective.png",
"function-surjective.png",
"function-general.png",
"function-kernel.png"
], ],
"File Hashes": { "File Hashes": {
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
@ -353,7 +358,7 @@
"_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f", "_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f",
"_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b", "_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b",
"set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53", "set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53",
"set/index.md": "7354797161e6720469801839b10b64c5", "set/index.md": "c103501e345a1b8201a26f2e83ed8379",
"set/graphs.md": "f0cd201673f2a999321dda6c726e8734", "set/graphs.md": "f0cd201673f2a999321dda6c726e8734",
"_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb", "_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb",
"_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391", "_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391",
@ -565,7 +570,7 @@
"_journal/2024-06/2024-06-12.md": "f82dfa74d0def8c3179d3d076f94558e", "_journal/2024-06/2024-06-12.md": "f82dfa74d0def8c3179d3d076f94558e",
"_journal/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "_journal/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307",
"_journal/2024-06/2024-06-13.md": "e2722a00585d94794a089e8035e05728", "_journal/2024-06/2024-06-13.md": "e2722a00585d94794a089e8035e05728",
"set/functions.md": "02b0f1e2a585e918e14a8ccf29fd578d", "set/functions.md": "ce565fbeb5298eeee0da828a89987ac4",
"_journal/2024-06-15.md": "92cb8dc5c98e10832fb70c0e3ab3cec4", "_journal/2024-06-15.md": "92cb8dc5c98e10832fb70c0e3ab3cec4",
"_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307",
"lambda-calculus/beta-reduction.md": "2074de1a5ab2171489239988a84b271f", "lambda-calculus/beta-reduction.md": "2074de1a5ab2171489239988a84b271f",
@ -715,7 +720,7 @@
"_journal/2024-08/2024-08-10.md": "08e7ea4a78c46645b93ec51e2372d04f", "_journal/2024-08/2024-08-10.md": "08e7ea4a78c46645b93ec51e2372d04f",
"_journal/2024-08-12.md": "8a37a2d1381f9d9e29d83031bad80dd0", "_journal/2024-08-12.md": "8a37a2d1381f9d9e29d83031bad80dd0",
"_journal/2024-08/2024-08-11.md": "acc91e07b43590e90846d2c936dcb3d5", "_journal/2024-08/2024-08-11.md": "acc91e07b43590e90846d2c936dcb3d5",
"c17/types.md": "941438a8f8377e348192d1822e765e40", "c17/types.md": "5ff85d535ee99d3e7aa79da93eb8383c",
"_journal/2024-08-14.md": "800650b9fa2f4445a174e0a547c2fa95", "_journal/2024-08-14.md": "800650b9fa2f4445a174e0a547c2fa95",
"_journal/2024-08/2024-08-13.md": "8b64225b06d1164a91176b123a3513a2", "_journal/2024-08/2024-08-13.md": "8b64225b06d1164a91176b123a3513a2",
"_journal/2024-08/2024-08-12.md": "e57b03b929410f3111c894e43e1728ec", "_journal/2024-08/2024-08-12.md": "e57b03b929410f3111c894e43e1728ec",
@ -723,7 +728,7 @@
"_journal/2024-08/2024-08-14.md": "f7d1dede5ab6e4634ad9de3d3426c6f7", "_journal/2024-08/2024-08-14.md": "f7d1dede5ab6e4634ad9de3d3426c6f7",
"_journal/2024-08-16.md": "a25c680684bcffc6a38cebbb448d9d97", "_journal/2024-08-16.md": "a25c680684bcffc6a38cebbb448d9d97",
"_journal/2024-08/2024-08-15.md": "7c3a96a25643b62b0064bf32cb17d92f", "_journal/2024-08/2024-08-15.md": "7c3a96a25643b62b0064bf32cb17d92f",
"_journal/2024-08-17.md": "375318b50134c7cb45a8eb08bc7e586d", "_journal/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee",
"_journal/2024-08/2024-08-16.md": "096d9147a9e3e7a947558f8dec763a2c", "_journal/2024-08/2024-08-16.md": "096d9147a9e3e7a947558f8dec763a2c",
"set/order.md": "373f4336d4845a3c2188d2215ac5fbc4" "set/order.md": "373f4336d4845a3c2188d2215ac5fbc4"
}, },

View File

@ -216,7 +216,7 @@ END%%
### Literals ### Literals
Negative integer literals are typed in a counterintuitive way. When the compiler sees a number of form `-X`, the type of `X` is determined *before* being negated. Promotion rules are as follows: Negative integer literals are typed in a counterintuitive way. When the compiler sees a number of form `-X`, the type of `X` is determined *before* being negated. Promotion follows the **first fit rule** described as follows:
| Decimal | Oct/Hex | | Decimal | Oct/Hex |
| ----------- | -------------------- | | ----------- | -------------------- |
@ -227,6 +227,69 @@ Negative integer literals are typed in a counterintuitive way. When the compiler
| `-` | `long long` | | `-` | `long long` |
| `-` | `unsigned long long` | | `-` | `unsigned long long` |
%%ANKI
Basic
What is the first fit rule?
Back: A specification on what type is given to an integer literal.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852091-->
END%%
%%ANKI
Basic
What is the signedness of a decimal integer literal?
Back: `signed`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852099-->
END%%
%%ANKI
Basic
What is the signedness of an octal integer literal?
Back: `signed` or `unsigned`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852105-->
END%%
%%ANKI
Basic
What is the signedness of a hexadecimal integer literal?
Back: `signed` or `unsigned`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852113-->
END%%
%%ANKI
Basic
The first fit rule lists what types (in order) for decimal integer literals?
Back: `int`, `long`, and `long long`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852124-->
END%%
%%ANKI
Basic
The first fit rule lists what types (in order) for octal integer literals?
Back: `int`, `unsigned`, `long`, `unsigned long`, `long long`, and `unsigned long long`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852132-->
END%%
%%ANKI
Basic
The first fit rule lists what types (in order) for hexadecimal integer literals?
Back: `int`, `unsigned`, `long`, `unsigned long`, `long long`, and `unsigned long long`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852139-->
END%%
%%ANKI
Basic
The first fit rule lists what types (in order) for hexadecimal integer literals?
Back: `int`, `unsigned`, `long`, `unsigned long`, `long long`, and `unsigned long long`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
END%%
%%ANKI %%ANKI
Basic Basic
How does the compiler process integer literal `-X`? How does the compiler process integer literal `-X`?
@ -267,6 +330,14 @@ Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems
<!--ID: 1710673807995--> <!--ID: 1710673807995-->
END%% END%%
%%ANKI
Basic
Why avoid negative hexadecimal integer literals?
Back: Depending on value, the resulting type may be `unsigned`.
Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723937852145-->
END%%
%%ANKI %%ANKI
Cloze Cloze
Octal literals are to {`0`} whereas hexadecimal literals are to {`0x`/`0X`}. Octal literals are to {`0`} whereas hexadecimal literals are to {`0x`/`0X`}.
@ -320,38 +391,6 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1708615249873--> <!--ID: 1708615249873-->
END%% END%%
%%ANKI
Basic
What suffix can be used to denote an `unsigned` integer literal?
Back: Case-insensitive `U`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708615249876-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `long` integer literal?
Back: Case-insensitive `L`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820847-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `long long` integer literal?
Back: Case-insensitive `LL`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820850-->
END%%
%%ANKI
Basic
What suffix can be used to denote an `unsigned long long` integer literal?
Back: Case-insensitive `ULL`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820856-->
END%%
%%ANKI %%ANKI
Basic Basic
In what order does C cast size and "signedness"? In what order does C cast size and "signedness"?
@ -419,6 +458,178 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1714677608769--> <!--ID: 1714677608769-->
END%% END%%
Integer constants can be forced to be unsigned or to be a type with minimal width by using the following suffixes:
| Suffix | Type |
| ------ | -------------------- |
| `U` | `unsigned` |
| `L` | `long` |
| `LL` | `long long` |
| `ULL` | `unsigned long long` |
%%ANKI
Basic
Is an integer literal without a suffix (e.g. `U`) signed or unsigned?
Back: This depends on the first fit rule.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723937852153-->
END%%
%%ANKI
Basic
What type is given to an integer literal without a suffix (e.g. `U`)?
Back: This depends on the first fit rule.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723938382384-->
END%%
%%ANKI
Basic
What suffix can be used to denote an `unsigned` integer literal?
Back: Case-insensitive `U`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708615249876-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `long` integer literal?
Back: Case-insensitive `L`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820847-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `long long` integer literal?
Back: Case-insensitive `LL`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820850-->
END%%
%%ANKI
Basic
What suffix can be used to denote an `unsigned long long` integer literal?
Back: Case-insensitive `ULL`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708631820856-->
END%%
%%ANKI
Basic
What type is given to integer literal `-1`?
Back: `int`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382388-->
END%%
%%ANKI
Basic
What type is given to integer literal `-1U`?
Back: `unsigned int`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382391-->
END%%
%%ANKI
Basic
What type is given to integer literal `1`?
Back: `int`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382394-->
END%%
%%ANKI
Basic
What type is given to integer literal `0x0U`?
Back: `unsigned int`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382398-->
END%%
## Floating Point
### Literals
Floating-point constants can be forced to be a type with minimal width by using the following suffixes:
| Suffix | Type |
| ------ | ------------- |
| `F` | `float` |
| `L` | `long double` |
%%ANKI
Basic
What type is given to a floating-point literal without a suffix (e.g. `F`)?
Back: `double`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1723938382401-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `float` floating-point literal?
Back: Case-insensitive `F`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382405-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `double` floating-point literal?
Back: N/A. Do not use a suffix.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382409-->
END%%
%%ANKI
Basic
What suffix can be used to denote a `long double` floating-point literal?
Back: Case-insensitive `L`.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382414-->
END%%
%%ANKI
Basic
What type is given to floating-point literal `-1.0`?
Back: `double`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382418-->
END%%
%%ANKI
Basic
What type is given to floating-point literal `-1.0F`?
Back: `float`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382423-->
END%%
%%ANKI
Basic
What type is given to floating-point literal `-1.0FL`?
Back: N/A. Invalid suffix.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382427-->
END%%
%%ANKI
Basic
What type is given to floating-point literal `-1.0L`?
Back: `long double`
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382432-->
END%%
%%ANKI
Basic
What type is given to floating-point literal `-1.0LL`?
Back: N/A. Invalid suffix.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1723938382436-->
END%%
## Bibliography ## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.

View File

@ -1313,6 +1313,7 @@ END%%
Cloze Cloze
Let $Q$, $A$, and $B$ be sets. Then {$Q \restriction (A - B)$} $=$ {$(Q \restriction A) - (Q \restriction B)$}. Let $Q$, $A$, and $B$ be sets. Then {$Q \restriction (A - B)$} $=$ {$(Q \restriction A) - (Q \restriction B)$}.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1723933434787-->
END%% END%%
%%ANKI %%ANKI

View File

@ -603,6 +603,14 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
<!--ID: 1716395245855--> <!--ID: 1716395245855-->
END%% END%%
%%ANKI
Basic
What does $\bigcup\,\{x\}$ evaluate to?
Back: $x$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1723933434782-->
END%%
### General Form ### General Form
For any set $A$, there exists a set $B$ whose elements are exactly the members of the members of $A$: $$\forall A, \exists B, \forall x, x \in B \Leftrightarrow (\exists b \in B, x \in b)$$ For any set $A$, there exists a set $B$ whose elements are exactly the members of the members of $A$: $$\forall A, \exists B, \forall x, x \in B \Leftrightarrow (\exists b \in B, x \in b)$$