-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update docs and add float16 conv test
- Loading branch information
Showing
3 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cbor | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestFloat16To32(t *testing.T) { | ||
for name, c := range map[string]struct { | ||
In uint16 | ||
Expect uint32 | ||
}{ | ||
"+infinity": { | ||
0b0_11111_0000000000, | ||
0b0_11111111_00000000000000000000000, | ||
}, | ||
"-infinity": { | ||
0b1_11111_0000000000, | ||
0b1_11111111_00000000000000000000000, | ||
}, | ||
"NaN": { | ||
0b0_11111_0101010101, | ||
0b0_11111111_01010101010000000000000, | ||
}, | ||
"absolute zero": {0, 0}, | ||
"subnormal": { | ||
0b0_00000_0001010000, | ||
0b0_01101101_01000000000000000000000, | ||
}, | ||
"normal": { | ||
0b0_00001_0001010000, | ||
0b0_0001110001_00010100000000000000000, | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
if actual := float16to32(c.In); c.Expect != actual { | ||
t.Errorf("%x != %x", c.Expect, actual) | ||
} | ||
}) | ||
} | ||
|
||
} |