fmt
All checks were successful
CI / Typos (pull_request) Successful in 9s
CI / Typst formatting (pull_request) Successful in 4s
CI / Build (pull_request) Successful in 6m3s
CI / Typos (push) Successful in 10s
CI / Typst formatting (push) Successful in 4s
CI / Build (push) Successful in 7m25s
All checks were successful
CI / Typos (pull_request) Successful in 9s
CI / Typst formatting (pull_request) Successful in 4s
CI / Build (pull_request) Successful in 6m3s
CI / Typos (push) Successful in 10s
CI / Typst formatting (push) Successful in 4s
CI / Build (push) Successful in 7m25s
This commit is contained in:
@ -31,7 +31,9 @@ Rewrite the following binary decimals in base 10: \
|
||||
#definition(label: "floatbits")
|
||||
Another way we can interpret a bit string is as a _signed floating-point decimal_, or a `float` for short. \
|
||||
Floats represent a subset of the real numbers, and are interpreted as follows: \
|
||||
#note([The following only applies to floats that consist of 32 bits. We won't encounter any others today.])
|
||||
#note(
|
||||
[The following only applies to floats that consist of 32 bits. We won't encounter any others today.],
|
||||
)
|
||||
|
||||
#align(center, box(inset: 2mm, cetz.canvas({
|
||||
import cetz.draw: *
|
||||
|
@ -131,9 +131,9 @@ $
|
||||
We then have:
|
||||
$
|
||||
log_2(x_f) & = log_2 ( 2^(E-127) times (1 + (F) / (2^23)) ) \
|
||||
& = E - 127 + log_2(1 + F / (2^23)) \
|
||||
& approx E-127 + F / (2^23) + epsilon \
|
||||
& = 1 / (2^23)(2^23 E + F) - 127 + epsilon \
|
||||
& = E - 127 + log_2(1 + F / (2^23)) \
|
||||
& approx E-127 + F / (2^23) + epsilon \
|
||||
& = 1 / (2^23)(2^23 E + F) - 127 + epsilon \
|
||||
& = 1 / (2^23)(x_i) - 127 + epsilon
|
||||
$
|
||||
])
|
||||
|
@ -156,9 +156,9 @@ float Q_rsqrt( float number ) {
|
||||
Using a calculator and some basic algebra, we can find the $epsilon$ this code uses: \
|
||||
#note[Remember, #text[`0x5f3759df`] is $6240089$ in hexadecimal.]
|
||||
$
|
||||
(3 times 2^22) (127 - epsilon) &= 6240089 \
|
||||
(127 - epsilon) &= 126.955 \
|
||||
epsilon &= 0.0450466
|
||||
(3 times 2^22) (127 - epsilon) & = 6240089 \
|
||||
(127 - epsilon) & = 126.955 \
|
||||
epsilon & = 0.0450466
|
||||
$
|
||||
|
||||
So, $0.045$ is the $epsilon$ used by Quake. \
|
||||
|
Reference in New Issue
Block a user