Closed jimsch closed 5 years ago
Here is the current situation:
Type
, CBORType.Number
.CBORObject.FromObject(0)
and CBORObject.FromObject(0.0)
as distinct items.CompareTo
method compares objects representing numbers (including integers, "doubles", "singles", decimal fractions, bigfloats, and rational numbers) according to their numerical values. One "kind" of number does not compare higher or lower than another kind in all cases.EInteger
.long
or as EInteger
depending on their value.ERational
.EFloat
.EDecimal
.float
.double
.First, I assume you meant to say tags 0 and 1 not 2 and 3 - Kind of hard to store a text string in an EInteger.
What I am currently playing with is CoRAL (https://datatracker.ietf.org/doc/draft-hartke-t2trg-coral/). There is a optimization with dictionaries that I need to figure out how to program. Looking inside of the object might be one way, but I would worry if you changed it again.
The hack is that you can replace specific elements in an array with an integer that comes from a dictionary so that [1, "ABCDE", "FGHIJ"] can be converted to [1, 10, 11] which is much shorter. The problem is that it is supposed to be possible to replace an integer value as well. Thus [1, "ABCDE", 99999] can be mapped to [1, 10, TBD(12)]. The value is tagged so that one can distinguish between it being an integer and being something else like a string. When doing the reverse mapping that means I need to figure out the difference between a floating point and an integer so that [1, 10, 12.0] is not mapped back. The model assumes that the tag that was decoded is visible to the application but I don't believe that is true for you systems.
Yes, when my library encounters CBOR objects with certain tags, it converts that object to a "native" version with a different form of storage and discards the tag; see ConvertToNativeObject
in the CBORNativeConvert
class of my library. However, it preserves the tag information in the case of all other tags.
I will work at rewriting the code to eliminate this kind of conversion and to preserve the distinction between integers and IEEE floating point numbers in the public API.
Thanks
Issue addressed in version 4.0.0-beta2, just released.
In the current working group document, the data model distinguishes between a floating point and an integer type. Section 2 - bullets 1 and 3. What are the plans for moving this into the current codebase?