Little o- and omega-notation.

c-declarations
Joshua Potter 2024-03-03 19:44:53 -07:00
parent aff3dbf43d
commit 5cc975f146
5 changed files with 440 additions and 7 deletions

View File

@ -135,7 +135,7 @@
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2", "algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
"algorithms/loop-invariant.md": "29f9f9090a3109890d333a78acc18b50", "algorithms/loop-invariant.md": "29f9f9090a3109890d333a78acc18b50",
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65", "algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
"algorithms/order-growth.md": "f4bab009ba9a6af34b9245fe595b0a2a", "algorithms/order-growth.md": "cf80f0fddaedbfb1959d05adbfe6cbee",
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac", "_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
"algorithms/sorting/selection-sort.md": "fcd0dc2ebaabd0a4db1baf7e7ef9f7a9", "algorithms/sorting/selection-sort.md": "fcd0dc2ebaabd0a4db1baf7e7ef9f7a9",
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97", "algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
@ -222,7 +222,7 @@
"filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa", "filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa",
"git/objects.md": "b95228a78744d3f9fe173e575aa0445a", "git/objects.md": "b95228a78744d3f9fe173e575aa0445a",
"git/index.md": "83d2d95fc549d9e8436946c7bd058d15", "git/index.md": "83d2d95fc549d9e8436946c7bd058d15",
"encoding/integer.md": "3107074a5070670f2f8fab17abc05fbb", "encoding/integer.md": "84a8343b1cf3cd1552c9fce3ef3e52b8",
"_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",
@ -232,7 +232,9 @@
"_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": "18925b0ecae151c3e6d38bc018c632c4", "algebra/sequences/triangular-numbers.md": "18925b0ecae151c3e6d38bc018c632c4",
"algebra/sequences/square-numbers.md": "886fb22fb8dbfffdd2cd233558ea3424" "algebra/sequences/square-numbers.md": "886fb22fb8dbfffdd2cd233558ea3424",
"_journal/2024-03-03.md": "c4977a3778ed227b768c3f9ad5512670",
"_journal/2024-03/2024-03-02.md": "8136792b0ee6e08232e4f60c88d461d2"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -0,0 +1,14 @@
---
title: "2024-03-03"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] Sheet Music (10 min.)
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)
* Began working through unsigned and two's-complement multiplication.
* Added notes on $o$- and $\omega$-notation.

View File

@ -169,6 +169,51 @@ Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambri
<!--ID: 1708974221871--> <!--ID: 1708974221871-->
END%% END%%
When encountering equations with asymptotic notation on both sides of the equality, we interpret the equation using the following rule:
> No matter how the anonymous functions are chosen on the left of the equal sign, there is a way to choose the anonymous functions on the right of the equal sign to make the equation valid.
For example, $2n^2 + \Theta(n) = \Theta(n^2)$ states that for all $f(n) \in \Theta(n)$, there exists some $g(n) \in \Theta(n^2)$ such that $2n^2 + f(n) = g(n)$.
%%ANKI
Basic
Asymptotic notation on the RHS of an equation is a stand in for what?
Back: *Some* function in the set that satisfies the equation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002305-->
END%%
%%ANKI
Basic
Asymptotic notation on the LHS of an equation is a stand in for what?
Back: *Any* function in the set.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002309-->
END%%
%%ANKI
Cloze
In equations containing asymptotic notation, {1:LHS} is to {1:$\forall$} whereas {2:RHS} is to {2:$\exists$}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002313-->
END%%
%%ANKI
Basic
How is $2n^2 + \Theta(n) = \Theta(n^2)$ written in propositional logic?
Back: $\forall f(n) \in \Theta(n), \exists g(n) \in \Theta(n^2), 2n^2 + f(n) = g(n)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002316-->
END%%
%%ANKI
Basic
*Why* is $\sum_{i=1}^n O(i) \neq O(1) + O(2) + \cdots + O(n)$?
Back: The number of anonymous functions is equal to the number of times the asymptotic notation appears.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002319-->
END%%
## $\Theta$-notation ## $\Theta$-notation
![[theta-notation.png]] ![[theta-notation.png]]
@ -437,7 +482,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Which notation corresponds to asymptotic upper bounds? Which notation corresponds to (potentially tight) asymptotic upper bounds?
Back: $O$-notation. Back: $O$-notation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009). Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709053894088--> <!--ID: 1709053894088-->
@ -509,6 +554,112 @@ Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambri
<!--ID: 1709053894105--> <!--ID: 1709053894105-->
END%% END%%
## $o$-notation
$o$-notation refers to an upper bound that is not asymptotically tight. It is defined as set $$o(g(n)) = \{ f(n) \mid \forall c > 0, \exists n_0 > 0, \forall n \geq n_0, 0 \leq f(n) < cg(n) \}$$
%%ANKI
Basic
What kind of mathematical object is $o(g(n))$?
Back: A set.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002323-->
END%%
%%ANKI
Basic
Using typical identifiers found in $o(g(n))$, what values do $c$ and $n_0$ take on?
Back: Positive constants.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002325-->
END%%
%%ANKI
Basic
What names are usually given to the existentially quantified identifers in $o(g(n))$'s definition?
Back: $n_0$.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002328-->
END%%
%%ANKI
Basic
What names are usually given to the universally quantified identifers in $o(g(n))$'s definition?
Back: $c$ and $n$.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002331-->
END%%
%%ANKI
Cloze
Using typical identifiers, $f(n) = o(g(n))$ satisfies {$0$} $\leq$ {$f(n)$} $<$ {$cg(n)$}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002334-->
END%%
%%ANKI
Basic
How does $o$-notation compare to $O$-notation?
Back: The former denotes an upper bound that is not asymptotically tight.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002337-->
END%%
%%ANKI
Basic
How is $o(g(n))$ pronounced?
Back: As "little-oh of $g$ of $n$".
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002340-->
END%%
%%ANKI
Basic
How can $f(n) = o(g(n))$ be expressed as a limit?
Back: $$\lim_{n \to \infty} \frac{f(n)}{g(n)} = 0$$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002344-->
END%%
%%ANKI
Basic
Which notation corresponds to asymptotic upper bounds that are not tight?
Back: $o$-notation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002347-->
END%%
%%ANKI
Basic
Every member of $o(g(n))$ is expected to be asymptotically what?
Back: Nonnegative.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002350-->
END%%
%%ANKI
Basic
How is $o(g(n))$ defined?
Back: $\{ \forall c > 0, \exists n_0 > 0, \forall n \geq n_0, 0 \leq f(n) < cg(n) \}$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002353-->
END%%
%%ANKI
Cloze
In $O(g(n))$, bound {1:$0 \leq f(n) \leq cg(n)$} holds for {1:some $c > 0$}. In $o(g(n))$, {2:$0 \leq f(n) < cg(n)$} holds for {2:all $c > 0$}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002359-->
END%%
%%ANKI
Basic
Is $O$-notation considered stronger or weaker than $o$-notation?
Back: Weaker.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002364-->
END%%
## $\Omega$-notation ## $\Omega$-notation
![[big-omega-notation.png]] ![[big-omega-notation.png]]
@ -595,7 +746,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Which notation corresponds to asymptotic lower bounds? Which notation corresponds to (potentially tight) asymptotic lower bounds?
Back: $\Omega$-notation. Back: $\Omega$-notation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009). Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709055157393--> <!--ID: 1709055157393-->
@ -665,6 +816,112 @@ Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambri
<!--ID: 1709055157406--> <!--ID: 1709055157406-->
END%% END%%
## $\omega$-notation
$\omega$-notation refers to a lower bound that is not asymptotically tight. It is defined as set $$\omega(g(n)) = \{ f(n) \mid \forall c > 0, \exists n_0 > 0, \forall n \geq n_0, 0 \leq cg(n) < f(n) \}$$
%%ANKI
Basic
What kind of mathematical object is $\omega(g(n))$?
Back: A set.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002369-->
END%%
%%ANKI
Basic
Using typical identifiers found in $\omega(g(n))$, what values do $c$ and $n_0$ take on?
Back: Positive constants.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002374-->
END%%
%%ANKI
Basic
What names are usually given to the existentially quantified identifers in $\omega(g(n))$'s definition?
Back: $n_0$.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002380-->
END%%
%%ANKI
Basic
What names are usually given to the universally quantified identifers in $\omega(g(n))$'s definition?
Back: $c$ and $n$.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002385-->
END%%
%%ANKI
Cloze
Using typical identifiers, $f(n) = \omega(g(n))$ satisfies {$0$} $\leq$ {$cg(n)$} $<$ {$f(n)$}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002390-->
END%%
%%ANKI
Basic
How does $\omega$-notation compare to $\Omega$-notation?
Back: The former denotes a lower bound that is not asymptotically tight.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002395-->
END%%
%%ANKI
Basic
How is $\omega(g(n))$ pronounced?
Back: As "little-omega of $g$ of $n$".
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002398-->
END%%
%%ANKI
Basic
How can $f(n) = \omega(g(n))$ be expressed as a limit?
Back: $$\lim_{n \to \infty} \frac{f(n)}{g(n)} = \infty$$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002402-->
END%%
%%ANKI
Basic
Which notation corresponds to asymptotic lower bounds that are not tight?
Back: $\omega$-notation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002406-->
END%%
%%ANKI
Basic
Every member of $\omega(g(n))$ is expected to be asymptotically what?
Back: Nonnegative.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002410-->
END%%
%%ANKI
Basic
How is $\omega(g(n))$ defined?
Back: $\{ \forall c > 0, \exists n_0 > 0, \forall n \geq n_0, 0 \leq cg(n) < f(n) \}$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002414-->
END%%
%%ANKI
Cloze
In $\Omega(g(n))$, bound {1:$0 \leq cg(n) \leq f(n)$} holds for {1:some $c > 0$}. In $\omega(g(n))$, {2:$0 \leq cg(n) < f(n)$} holds for {2:all $c > 0$}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002420-->
END%%
%%ANKI
Basic
Is $\omega$-notation considered stronger or weaker than $\Omega$-notation?
Back: Stronger.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
<!--ID: 1709519002425-->
END%%
## References ## References
* 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).

View File

@ -720,6 +720,13 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1708615249914--> <!--ID: 1708615249914-->
END%% END%%
%%ANKI
Cloze
For all $x$, $T2U_w(x)=$ {$x + x_{w-1}2^w$} where $x_{w-1}$ is the most significant bit of $x$.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205954-->
END%%
%%ANKI %%ANKI
Basic Basic
How is $T2U_w$ written as a function composition? How is $T2U_w$ written as a function composition?
@ -1083,7 +1090,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why can we compare $s$ to $x$ or $y$ when detecting overflow of $s \coloneqq x +_w^u y$? Why can we choose to compare $s$ to either $x$ or $y$ when detecting overflow of $s \coloneqq x +_w^u y$?
Back: Because unsigned addition is commutative. Back: Because unsigned addition is commutative.
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: 1708799678776--> <!--ID: 1708799678776-->
@ -1121,6 +1128,22 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1709042784788--> <!--ID: 1709042784788-->
END%% END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the largest possible value of $x +_w^u y$?
Back: $w + 1$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205961-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the smallest possible value of $x +_w^u y$?
Back: $w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205964-->
END%%
Two's-complement addition, denoted $+_w^t$ operates similarly: Two's-complement addition, denoted $+_w^t$ operates similarly:
$$x +_w^u y = \begin{cases} $$x +_w^u y = \begin{cases}
@ -1141,7 +1164,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why is two's-complement addition overflow UB? Why is signed addition overflow UB?
Back: Because the C standard does not mandate any particular signed integer encoding. Back: Because the C standard does not mandate any particular signed integer encoding.
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.
Tags: c17 Tags: c17
@ -1209,6 +1232,14 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1708964376254--> <!--ID: 1708964376254-->
END%% END%%
%%ANKI
Basic
How is the following expressed more simply (i.e. using more standard algebra)? $$x +_w^t y = U2T_w(T2U_w(x) +_w^u T2U_w(y))$$
Back: $x +_w^t y = U2T_w((x + y) \bmod 2^w)$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205967-->
END%%
%%ANKI %%ANKI
*Why* are we able to characterize $+_w^t$ in terms of $+_w^u$? *Why* are we able to characterize $+_w^t$ in terms of $+_w^u$?
Back: Because two's-complement addition has the same bit-level representation as unsigned addition. Back: Because two's-complement addition has the same bit-level representation as unsigned addition.
@ -1320,6 +1351,135 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1709044103781--> <!--ID: 1709044103781-->
END%% END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the largest possible value of $x +_w^t y$?
Back: $w + 1$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205970-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the smallest possible value of $x +_w^t y$?
Back: $w + 1$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205974-->
END%%
### Multiplication
Unsigned multiplication, denoted with the $*_w^u$ operator, is defined as follows: $$x *_w^u y = (x \cdot y) \bmod 2^w$$
%%ANKI
Basic
What does $*_w^u$ denote?
Back: Unsigned multiplication of $w$-bit integral types.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205977-->
END%%
%%ANKI
Basic
What is the result of $x *_w^u y$?
Back: $(x \cdot y) \bmod 2^w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205981-->
END%%
%%ANKI
Basic
*Why* does $x *_w^u y = (x \cdot y) \bmod 2^w$ (at least in C)?
Back: Because unsigned multiplication is *defined* to be the result truncated to $w$ bits.
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: 1709492205984-->
END%%
%%ANKI
Basic
How do $+_w^u$ and $*_w^u$ behave similarly?
Back: Letting $\square$ denote either $+$ or $*$, both satisfy $x \;\square_w^u\; y = (x \;\square\; y) \bmod 2^w$.
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: 1709492205988-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the largest possible value of $x *_w^u y$?
Back: $2w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205991-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the smallest possible value of $x *_w^u y$?
Back: $w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205995-->
END%%
Similarly, two's-complement multiplication is defined as follows: $$x *_w^t y = U2T_w((x \cdot y) \bmod 2^w)$$
%%ANKI
Basic
What does $*_w^t$ denote?
Back: Two's-complement multiplication of $w$-bit integral types.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492205998-->
END%%
%%ANKI
Basic
What is the result of $x *_w^t y$?
Back: $U2T_w((x \cdot y) \bmod 2^w)$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492206002-->
END%%
%%ANKI
Basic
How do $+_w^t$ and $*_w^t$ behave similarly?
Back: Letting $\square$ denote either $+$ or $*$, both satisfy $x \;\square_w^t\; y = U2T_w((x \;\square\; y) \bmod 2^w)$.
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: 1709492206006-->
END%%
%%ANKI
Basic
How can we write $x *_w^t y$ in terms of unsigned multiplication?
Back: $x *_w^t y = U2T_w(T2U_w(x) *_w^u T2U_w(y))$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492206012-->
END%%
%%ANKI
Basic
How is the following expressed more simply (i.e. using more standard algebra)? $$x *_w^t y = U2T_w(T2U_w(x) *_w^u T2U_w(y))$$
Back: $x *_w^t y = U2T_w((x \cdot y) \bmod 2^w)$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492206017-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the largest possible value of $x *_w^t y$?
Back: $2w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492206024-->
END%%
%%ANKI
Basic
Ignoring overflow, what is the width of the smallest possible value of $x *_w^t y$?
Back: $2w$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1709492206031-->
END%%
### Shifting ### Shifting
Left shift operations (`<<`) drop the `k` most significant bits and fills the right end of the result with `k` zeros. Right shift operations (`>>`) are classified in two ways: Left shift operations (`<<`) drop the `k` most significant bits and fills the right end of the result with `k` zeros. Right shift operations (`>>`) are classified in two ways: