# HG changeset patch
# User Henry Precheur
# Date 1571592817 25200
# Sun Oct 20 10:33:37 2019 -0700
# Node ID 3aba14aac9bf905e1944b7c390f27c505401ae2a
# Parent d979883337708e6f4da6ac4701fbe83f40dfbd8f
wip
diff --git a/episode10/README.md b/episode10/README.md
--- a/episode10/README.md
+++ b/episode10/README.md
@@ -36,24 +36,24 @@
----
In the [previous episode][ep9] we added floating point number support to our
-encoder. We took care to minimize the size of the output by using small floats
-when appropriate. There’s still room for improvement: we encode regular
-floating point numbers efficiently, but there are also special numbers on the
-standard IEEE 754 that we haven’t dealt with yet and that can be packed most
-efficiently:
+encoder. We minimized the size of the output by using small floats when
+appropriate. While our encoder can encode any floating point number, we can
+minimize the out further: we encode regular floating point numbers efficiently,
+but we didn’t optimize special numbers. There are 3 types of special numbers
+from the standard IEEE 754 that we can packed more efficiently:
+- Infinities
+- Not a Number
- Subnumbers, also called denormal numbers, denormalized numbers, or subnormal
numbers. They includes 0 which can’t be encoded accurately as a regular
floating point number
-- Infinities
-- Not a Number
-The way the encoder works now these special values are all encoded as 64 bits
-floats, but most of them we can be encoded as 16 bits numbers without losing
+How the encoder works now these special values are all encoded as 64 bits
+floats. Most of them we can be encoded as 16 bits numbers without losing
information.
-We’ll starts with infinite values, then not a number values, and finish with the
-most challenging case: subnormal numbers.
+We’ll starts with infinite values, then ‘not a number’ values, and finish with
+the most challenging type: subnormal numbers.
There are too types of infinite values: positive and negative. Infinite values
are encoded with the sign bit, all 1’s in the exponent, and all 0’s for the
@@ -69,15 +69,13 @@
...
}
-Not a number or NaN is similar to infinites but with a non-zero fractional part.
-The fractional part of a NaN carries some information, we’ll copy as is and just
-chop off the end because all the important information is in the first few bits.
-We add the following the second switch statement:
+Not a number or NaN values are similar to infinites, but they have a non-zero
+fractional part. The fractional part of a NaN carries some information, we’ll
+copy as is and just chop off the end because all the important information is in
+the first few bits. We add the following the second switch statement:
func (e *Encoder) writeFloat(input float64) error {
- if math.IsInf(input, 0) {
- return e.writeFloat16(math.Signbit(input), (1< (−1)^{signbit} × 2^{exponent−15} × 1.significantbits_{2}
diff --git a/episode10/cbor.go b/episode10/cbor.go
--- a/episode10/cbor.go
+++ b/episode10/cbor.go
@@ -178,7 +178,7 @@
}
func (e *Encoder) writeFloat(input float64) error {
- // First check if we have a special value: 0, NaN, Inf, -Inf
+ // First check if we have a special value: 0, Inf, -Inf
switch {
case input == 0:
return e.writeFloat16(math.Signbit(input), 0, 0)