More floating-point notes.
parent
444418d78e
commit
809414ede4
|
@ -212,10 +212,10 @@
|
|||
"_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7",
|
||||
"_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd",
|
||||
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
|
||||
"c17/strings.md": "d8a1193ecbbc43aa81539585babb91b1",
|
||||
"c17/strings.md": "3335356dee2b0e28a356adc851ee1375",
|
||||
"c17/index.md": "78576ee41d0185df82c59999142f4edb",
|
||||
"c17/escape-sequences.md": "ebc63c6cdfbe60bbc2708c1b0c8da8bb",
|
||||
"c17/declarations.md": "20e200f2b7abcab8f873cd080f4c9770",
|
||||
"c17/declarations.md": "cec6866dff8ad160467df62cfceb6872",
|
||||
"algorithms/sorting/merge-sort.md": "fdc6311b0f9e7d85899fc77a95872a2f",
|
||||
"_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4",
|
||||
"_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7",
|
||||
|
@ -231,7 +231,7 @@
|
|||
"filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa",
|
||||
"git/objects.md": "e9b98576291ca04496c2f0863f526cfa",
|
||||
"git/index.md": "83d2d95fc549d9e8436946c7bd058d15",
|
||||
"encoding/integer.md": "87f6b405cc33a5f8517588928b0cb17e",
|
||||
"encoding/integer.md": "14cbb409fde144875d75eefc53ce7f35",
|
||||
"_journal/2024-02-29.md": "f610f3caed659c1de3eed5f226cab508",
|
||||
"_journal/2024-02/2024-02-28.md": "7489377c014a2ff3c535d581961b5b82",
|
||||
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
|
||||
|
@ -270,10 +270,13 @@
|
|||
"_journal/2024-03/2024-03-13.md": "6a2ad92d0983c36acef93932bfec1758",
|
||||
"git/references.md": "73792b2c7a0700a58336e045915ba0d4",
|
||||
"_journal/2024-03-15.md": "a1f0ba85b8d3dd8cf1976373298eb717",
|
||||
"encoding/float.md": "4a1b49e2f3223c913dfdf469429002bd",
|
||||
"encoding/float.md": "5c3f06d8efe031e341cd295ff235adcc",
|
||||
"_journal/2024-03/2024-03-14.md": "1c173cab2e903aad876c5f11d49a8b20",
|
||||
"_journal/2024-03-16.md": "ef1bcb4d28790c8a32691ddedd6c289f",
|
||||
"_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39"
|
||||
"_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39",
|
||||
"_journal/2024-03-17.md": "72e99c7630085aee2c7f340a06b5ada7",
|
||||
"_journal/2024-03/2024-03-16.md": "ab7629c24ebe70838072cf6acec47cb0",
|
||||
"encoding/floating-point.md": "6aa91498473ea5f8504dfa7f87bf77f4"
|
||||
},
|
||||
"fields_dict": {
|
||||
"Basic": [
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: "2024-03-17"
|
||||
---
|
||||
|
||||
- [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)
|
||||
|
||||
* Finished translating `printf` to all relevant flashcards.
|
||||
* Finish chapter 2 of "Computer Systems: A Programmer's Perspective".
|
||||
* Last portion was on floating-point encoding.
|
|
@ -232,6 +232,14 @@ Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems
|
|||
<!--ID: 1708631820826-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How do we specify an octal integer literal?
|
||||
Back: Prepend the literal with a `0`.
|
||||
Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710673807992-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why avoid negative octal integer literals?
|
||||
|
@ -240,6 +248,21 @@ Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems
|
|||
<!--ID: 1708631820829-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How do we specify a hexadecimal integer literal?
|
||||
Back: Prepend the literal with a `0x` or `0X`.
|
||||
Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710673807995-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Octal literals are to {`0`} whereas hexadecimal literals are to {`0x`/`0X`}.
|
||||
Reference: Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710673807997-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why avoid negative hexadecimal integer literals?
|
||||
|
|
|
@ -80,12 +80,13 @@ Tags: printf
|
|||
<!--ID: 1708425941269-->
|
||||
END%%
|
||||
|
||||
| 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 |
|
||||
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
|
||||
`#` | For `g` and `G`, trailing zeros are not removed. For `f`, `F`, `e`, `E`, `g`, and `G`, output always has a decimal point. For `o`, `x`, and `X`, the text `0`, `0x`, and `0X` is prepended to non-zero numbers respectively.
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
|
@ -272,6 +273,77 @@ Tags: printf
|
|||
<!--ID: 1707918756888-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#g` different from `%g`?
|
||||
Back: The former always includes a decimal point and may include trailing `0`s.
|
||||
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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807973-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#f` different from `%f`?
|
||||
Back: The former always includes a decimal point.
|
||||
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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807976-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#e` different from `%e`?
|
||||
Back: The former always includes a decimal point.
|
||||
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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807979-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which `printf` flag can be used to ensure decimal points in the output of floating-point types?
|
||||
Back: `#`
|
||||
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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807981-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#o` different from `%o`?
|
||||
Back: The former prepends a `0` to 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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807983-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#x` different from `%x`?
|
||||
Back: The former prepends a `0x` to 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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807986-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `%#X` different from `%X`?
|
||||
Back: The former prepends a `0X` to 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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807988-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
`%#o` is to {`0`} as `%#x` is to {`0x`}.
|
||||
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).
|
||||
Tags: printf
|
||||
<!--ID: 1710673807990-->
|
||||
END%%
|
||||
|
||||
Length | Description
|
||||
--------- | -----------
|
||||
`hh` | `int` sized integer argument promoted from a `char`
|
||||
|
@ -488,6 +560,42 @@ Tags: printf
|
|||
<!--ID: 1710450347012-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming round-to-even, what is the output of `printf("%.0f", 3.5)`?
|
||||
Back: `4`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
Tags: printf
|
||||
<!--ID: 1710675908301-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming round-to-even, what is the output of `printf("%.0f", 2.5)`?
|
||||
Back: `2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
Tags: printf
|
||||
<!--ID: 1710675908304-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does the C standard define the rounding mode of floating-point specifiers?
|
||||
Back: This is implementation specific.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
Tags: printf
|
||||
<!--ID: 1710675908306-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does the rounding mode of floating-point specifiers refer to?
|
||||
Back: How numbers with greater than the specified precision are output.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
Tags: printf
|
||||
<!--ID: 1710675908307-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What three special identifiers might specifier `%F` output?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Float Encoding
|
||||
title: Floating Point
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: binary::float ieee
|
||||
tags:
|
||||
|
@ -10,18 +10,22 @@ tags:
|
|||
|
||||
## Overview
|
||||
|
||||
The IEEE floating-point standard defines an encoding used to represent numbers of form $$(-1)^s \times M \times 2^E$$ where $s$ denotes the **sign bit**, $M$ the **significand**, and $E$ the **exponent**. The binary representation of floating point numbers are segmented into three fields: the sign bit, the exponent field, and the fraction field. Furthermore, there are two forms these fields are interpreted with respect to:
|
||||
The IEEE floating-point standard defines an encoding used to represent numbers of form $$(-1)^s \times M \times 2^E$$ where $s$ denotes the **sign bit**, $M$ the **significand**, and $E$ the **exponent**. The binary representation of floating point numbers are segmented into three fields: the sign bit, the exponent field, and the fraction field. Furthermore, there are three classes these fields are interpreted with respect to:
|
||||
|
||||
* Normalized Form
|
||||
* Here the exponent field is neither all `0`s nor all `1`s.
|
||||
* The significand is $1 + f$, where $f$ denotes the fractional part.
|
||||
* $E = e - Bias$ where $e$ is the unsigned interpretation of the exponent field.
|
||||
* Denormalized Form
|
||||
* Here the exponent field is either all `0`s or all `1`s.
|
||||
* Here the exponent field is all `0`s.
|
||||
* The significand is $f$, where $f$ denotes the fractional part.
|
||||
* $E = 1 - Bias$, defined for smooth transition between normalized and denormalized values.
|
||||
* Special Values
|
||||
* Here the exponent field is all `1`s.
|
||||
* If the fraction field is all `0`s, we have an $\infty$ value.
|
||||
* If the fraction field is not all `0`s, we have $NaN$.
|
||||
|
||||
The $Bias$ in both forms is set to $2^{k - 1} - 1$ where $k$ denotes the number of bits that make up the exponent field. In C, fields have the following widths:
|
||||
The $Bias$ in the first two forms is set to $2^{k - 1} - 1$ where $k$ denotes the number of bits that make up the exponent field. In C, fields have the following widths:
|
||||
|
||||
Declaration | Sign Bit | Exponent Field | Fractional Field
|
||||
----------- | -------- | -------------- | ----------------
|
||||
|
@ -158,7 +162,7 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
What IEEE standard describes floating point operations?
|
||||
What IEEE standard (number) describes floating point operations?
|
||||
Back: 754
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710556914957-->
|
||||
|
@ -167,7 +171,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
What alternative name does IEEE Standard 754 go by?
|
||||
Back: IEEE floating point
|
||||
Back: IEEE floating-point
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710556914959-->
|
||||
END%%
|
||||
|
@ -256,7 +260,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
What visualization explains why $0.11\cdots1_2 = 1 - 2^{-n}$?
|
||||
Back: Each additional $1$ halves the remaining interval.
|
||||
Back: Each additional $1$ adds half of the remaining interval to a running total.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710556914982-->
|
||||
END%%
|
||||
|
@ -558,7 +562,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
When is a floating-point number considered denormalized?
|
||||
Back: When the exponent field is either all `0`s or all `1`s.
|
||||
Back: When the exponent field is all `0`s.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710556915061-->
|
||||
END%%
|
||||
|
@ -953,6 +957,503 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1710605798354-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What three forms can an IEEE floating-point number take on?
|
||||
Back: Normalized, denormalized, and special value.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470749-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
When is a floating-point number considered a special value?
|
||||
Back: When the exponent field is all `1`s.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470791-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What special values can a floating-point number take on?
|
||||
Back: $\infty$ and $NaN$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470794-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Representable floating-point numbers are denser around what?
|
||||
Back: $0$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470797-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
IEEE floating-point was designed to allow efficiently sorting using what?
|
||||
Back: An integer sorting routine.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470799-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* can IEEE floating-point values be sorted using an integer sorting routine?
|
||||
Back: The unsigned interpretation of ascending floating-point numbers is also ascending.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470801-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What complication exists in integer sorting routines applied to IEEE floating-point values?
|
||||
Back: The unsigned interpretation of negative floating-point numbers is in descending order.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710672470805-->
|
||||
END%%
|
||||
|
||||
## Rounding
|
||||
|
||||
Because floating-point arithmetic can't represent every real number, it must round results to the "nearest" representable number, however "nearest" is defined. The IEEE floating-point standard defines four **rounding modes** to influence this behavior:
|
||||
|
||||
* **Round-to-even** rounds numbers to the closest representable value. In the case of values equally between two representations, it rounds to the number with an even least significant digit.
|
||||
* **Round-toward-zero** rounds downward for positive values and upward for negative values.
|
||||
* **Round-down** always rounds downward.
|
||||
* **Round-up** always rounds upward.
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What are the four rounding modes supported in the IEEE floating-point standard?
|
||||
Back: Round-to-even, round-toward-zero, round-down, and round-up.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824748-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{1:Round-toward-zero} is to {2:integer} division whereas {2:round-down} is to {1:floor} division.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824750-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{1:Round-up} is to {2:ceiling} division whereas {2:round-toward-zero} is to {1:integer} division.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824752-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the default IEEE floating-point standard rounding mode?
|
||||
Back: Round-to-even.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824754-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What alternative name does round-to-even go by?
|
||||
Back: Round-to-nearest.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824757-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.40` rounded in round-to-even mode?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824759-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.50` rounded in round-to-even mode?
|
||||
Back: `2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824761-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.60` rounded in round-to-even mode?
|
||||
Back: `2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824763-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `-1.50` rounded in round-to-even mode?
|
||||
Back: `-2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824765-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.40` rounded in round-to-zero mode?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824767-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.50` rounded in round-to-zero mode?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824769-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `-1.50` rounded in round-to-zero mode?
|
||||
Back: `-1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824771-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.40` rounded in round-down mode?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824774-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.50` rounded in round-down mode?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824776-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `-1.50` rounded in round-down mode?
|
||||
Back: `-2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824778-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.40` rounded in round-up mode?
|
||||
Back: `2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824780-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `1.50` rounded in round-up mode?
|
||||
Back: `2`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824782-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is floating-point `-1.50` rounded in round-up mode?
|
||||
Back: `-1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824785-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* does round-to-even prefer even over odd numbers?
|
||||
Back: This is an arbitrary choice.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824787-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* does round-to-even prefer even over always rounding down?
|
||||
Back: The former more reliably avoids potential statistical biases.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824790-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In round-to-even rounding, what bit is considered even?
|
||||
Back: `0`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824792-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In round-to-even rounding, what bit is considered odd?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824794-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does the IEEE floating-point standard define $1/-0$?
|
||||
Back: $-\infty$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824796-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does the IEEE floating-point standard define $1/+0$?
|
||||
Back: $\infty$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824798-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What value(s) do IEEE floating-point numbers take on in the case of overflow?
|
||||
Back: $\pm\infty$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824800-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What value(s) do IEEE floating-point numbers take on in the case of underflow?
|
||||
Back: $0$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824802-->
|
||||
END%%
|
||||
|
||||
## Arithmetic
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does $+^f$ denote?
|
||||
Back: Floating-point addition.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824805-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the result of $x +^f y$?
|
||||
Back: $Round(x + y)$ where $Round$ refers to the current rounding-mode.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824808-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+^f$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824810-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+^f$ associative?
|
||||
Back: No.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824813-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which IEEE floating-point values do not have an additive inverse?
|
||||
Back: $\pm\infty$ and $NaN$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824815-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Let $f$ be a normalized floating-point value. What is its additive inverse?
|
||||
Back: $-f$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824817-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Let $f$ be a denormalized floating-point value. What is its additive inverse?
|
||||
Back: $-f$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824819-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Let $f$ be a special floating-point value. What is its additive inverse?
|
||||
Back: N/A
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824822-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the most important group quality $+^f$ is lacking?
|
||||
Back: Associativity.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824824-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does $*^f$ denote?
|
||||
Back: Floating-point multiplication.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824826-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the result of $x *^f* y$?
|
||||
Back: $Round(x * y)$ where $Round$ refers to the current rounding-mode.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824827-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*^f$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824829-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*^f$ associative?
|
||||
Back: No.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824832-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the multiplicative identity of $*^f$?
|
||||
Back: $1.0$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824834-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does $*^f$ distribute over $+^f$?
|
||||
Back: No.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824836-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What property of floating-point values prevents it behaving like "real math"?
|
||||
Back: It represents a finite number of values and rounds results if need be.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824838-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is precision affected when casting from `float` to `double`?
|
||||
Back: It isn't.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824841-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is precision affected when casting from `double` to `float`?
|
||||
Back: Rounding may occur.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824844-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* might rounding occur when casting from `double` to `float`?
|
||||
Back: `float`s have less precision.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824846-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What overflow values might result when casting from `float` to `double`?
|
||||
Back: N/A
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824848-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What overflow values might result when casting from `double` to `float`?
|
||||
Back: $\pm\infty$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824850-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* might overflow occur when casting from `double` to `float`?
|
||||
Back: `float`s have smaller range.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824852-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming no overflow, what is the result of casting a `double` to an `int`?
|
||||
Back: The `double`'s value rounded toward `0`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824856-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming overflow, what is the result of casting a `double` to an `int`?
|
||||
Back: The result is implementation-specific.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824858-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming no overflow, what is the result of casting a `float` to an `int`?
|
||||
Back: The `float`'s value rounded toward `0`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824861-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the result of `(int) (double) 1.5`?
|
||||
Back: `1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824863-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the result of `(int) (double) -1.5`?
|
||||
Back: `-1`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824865-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Assuming overflow, what is the result of casting a `float` to an `int`?
|
||||
Back: The result is implementation-specific.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824867-->
|
||||
END%%
|
||||
|
||||
## References
|
||||
|
||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Integer Encoding
|
||||
title: Integers
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: binary::integer
|
||||
tags:
|
||||
|
@ -230,7 +230,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
How does Bryant et al. define $B2U_w$?
|
||||
Back: $B2U_w(\vec{x}) = 2^{w-1}x_{w-1} + \sum_{i=0}^{w-2} 2^ix_i$
|
||||
Back: $B2U_w(\vec{x}) = 2^{w-1}x_{w-1} + \sum_{k=0}^{w-2} 2^kx_k$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1708179147785-->
|
||||
END%%
|
||||
|
@ -415,7 +415,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
How does Bryant et al. define $B2T_w$?
|
||||
Back: $B2T_w(\vec{x}) = -2^{w-1}x_{w-1} + \sum_{i=0}^{w-2} 2^ix_i$
|
||||
Back: $B2T_w(\vec{x}) = -2^{w-1}x_{w-1} + \sum_{k=0}^{w-2} 2^kx_k$
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1708179649901-->
|
||||
END%%
|
||||
|
@ -1138,6 +1138,22 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1709492205964-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+_w^u$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824725-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+_w^u$ associative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824728-->
|
||||
END%%
|
||||
|
||||
Two's-complement addition, denoted $+_w^t$ operates similarly:
|
||||
|
||||
$$x +_w^u y = \begin{cases}
|
||||
|
@ -1361,6 +1377,22 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1709492205974-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+_w^t$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824730-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $+_w^t$ associative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824733-->
|
||||
END%%
|
||||
|
||||
### 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:
|
||||
|
@ -1677,6 +1709,30 @@ Tags: c17
|
|||
<!--ID: 1709831032382-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*_w^u$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824735-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*_w^u$ associative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824737-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does $*^u_w$ distribute over $+^u_w$?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824740-->
|
||||
END%%
|
||||
|
||||
Similarly, two's-complement multiplication is defined as follows: $$x *_w^t y = U2T_w((x \cdot y) \bmod 2^w)$$
|
||||
|
||||
%%ANKI
|
||||
|
@ -1815,6 +1871,30 @@ Tags: c17
|
|||
<!--ID: 1709831032386-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*_w^t$ commutative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824742-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is $*_w^t$ associative?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824744-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does $*^t_w$ distribute over $+^t_w$?
|
||||
Back: Yes.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1710680824746-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How can we rewrite $x \cdot 1101_2$ as an expression of *only* `<<` and `+`?
|
||||
|
|
Loading…
Reference in New Issue