Document lack of half-precision float

dev
Alberto Restifo 2020-04-24 11:37:41 +02:00
parent a78d06f33a
commit 4929f2487b
4 changed files with 21 additions and 13 deletions

View File

@ -7,7 +7,6 @@ in Crystal.
## Features
- Full RFC7049 support
- Full support for diagnostic notation
- Assign a field to a type base on the CBOR tag
- Support for a wide range of IANA CBOR Tags
@ -19,6 +18,9 @@ in Crystal.
Crystal doesn't have a `Float16` type, so half-precision floating point numbers
are not supported for the time being.
If you know of a way to solve handle half-precision float, a contribution would
be really appreciated.
### Maximum Array/String array/Bytes array length
The spec allows for the maximum length of arrays, string arrays and bytes array

View File

@ -3,6 +3,19 @@ require "./spec_helper"
# All those tests have been exported from the RFC7049 appendix A.
tests = [
# Disabled as half-precision floats are not supported:
# { %(0.0), "f9 00 00" },
# { %(-0.0), "f9 80 00" },
# { %(1.0), "f9 3c 00" },
# { %(1.5), "f9 3e 00" },
# { %(65504.0), "f9 7b ff" },
# { %(0.00006103515625), "f9 04 00" },
# { %(-4.0), "f9 c4 00" },
# { %(5.960464477539063e-8), "f9 00 01" },
# { %(Infinity), "f9 7c 00" },
# { %(NaN), "f9 7e 00" },
# { %(-Infinity), "f9 fc 00" },
{ %(0), "00" },
{ %(1), "01" },
{ %(10), "0a" },
@ -21,22 +34,11 @@ tests = [
{ %(-10), "29" },
{ %(-100), "38 63" },
{ %(-1000), "39 03 e7" },
# { %(0.0), "f9 00 00" },
# { %(-0.0), "f9 80 00" },
# { %(1.0), "f9 3c 00" },
{ %(1.1), "fb 3f f1 99 99 99 99 99 9a" },
# { %(1.5), "f9 3e 00" },
# { %(65504.0), "f9 7b ff" },
{ %(100000.0), "fa 47 c3 50 00" },
# { %(3.4028234663852886e+38), "fa 7f 7f ff ff" }, TODO: Not precise enough?
{ %(1.0e+300), "fb 7e 37 e4 3c 88 00 75 9c" },
# { %(5.960464477539063e-8), "f9 00 01" },
# { %(0.00006103515625), "f9 04 00" },
# { %(-4.0), "f9 c4 00" },
{ %(-4.1), "fb c0 10 66 66 66 66 66 66" },
# { %(Infinity), "f9 7c 00" },
# { %(NaN), "f9 7e 00" },
# { %(-Infinity), "f9 fc 00" },
{ %(Infinity), "fa 7f 80 00 00" },
{ %(NaN), "fa 7f c0 00 00" },
{ %(-Infinity), "fa ff 80 00 00" },

View File

@ -84,7 +84,7 @@ class CBOR::Lexer
when 0xe0..0xf8
consume_simple_value(read_size(byte - 0xe0))
when 0xf9
raise ParseError.new("Half-precision floating points are not supported")
raise ParseError.new("Half-precision floating point numbers are not supported")
when 0xfa
Token::FloatT.new(value: read(Float32))
when 0xfb

View File

@ -21,6 +21,10 @@ enum CBOR::Tag : UInt32
RegularExpression
MimeMessage
UUID
Language
Identifier
CBORWebToken = 61
CBORMarker = 55799
end