Open janpoltan opened 2 years ago
Can you please add yourself to the contributors section in package.json?
Added option to force encoding of non integer values to 4 byte float.
After trying to write tests for this, I'd like to discuss what happens with large floats. They are currently encoded as a 32-bit Infinity
(fa 7f 80 00 00), which is different than the 16-bit Infinity
that cbor.encode(Infinity)
produces (f9 7c 00). I see a couple of options:
Of those, document is the easiest of course. Error has precedent, there are several ways to cause an Error to be thrown in Encode - the only niggle is how to detect the issue, but perhaps a couple of checks in _pushFloatBE
would work (check the buffer after writing for Infinity and -Infinity). I don't really like the third option.
Regardless, we need to change _pushInfinity
, _pushNaN
, and _pushIntNum
's -0 handling to look at useFloat32bit
also.
I'm assuming I understand your use case, but can you explain it here so we've got it on the record, please?