-
KDL allows numbers to be specified either as integer, float/decimal, hex, octal, binary or scientific notation The spec states
As an implementer, I take that to mean that internally I can represent all kinds of numbers using a 64 bit int, a byte array, or whatever internal format of my choosing. However, when generating/outputting KDL, the spec doesn't say anything about number formats. I'm not sure whether I need to preserve the number's input format, or whether I can "squash" it down to whatever format suits me. By example: When round-tripping this KDL document, do I need to output back the exact input of
Or can I simply output this?
If the KDL language definition is fine with the latter, could you please add a note to the spec about round-tripping numbers and that this is not expected? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Aside: my personal opinion is that while it’s probably ok to squash things like 0xA and 1e1 down to “10”, a well behaved implementation shouldn’t squash a floating point/decimal number down into an integer, as that represents a different data type and might be significant. IE: 10.0 should not squash down to 10, but other squashing seems fair game |
Beta Was this translation helpful? Give feedback.
-
You can output numbers any way you want. Implementations for people who actually care about formatting would need to be document-oriented and have extra data structures or options that tell the KDL handler how to actually write out the data. Does that make sense? That means outputting |
Beta Was this translation helpful? Give feedback.
You can output numbers any way you want. Implementations for people who actually care about formatting would need to be document-oriented and have extra data structures or options that tell the KDL handler how to actually write out the data. Does that make sense? That means outputting
ten 10 10 10 10 10 10
is totally fine. It's the same value. The various input syntaxes are only different in syntax, not semantics.