Stream: dotnet
Topic: exponential
Angus Millar (Apr 14 2020 at 14:47):
I have noticed that when I round trip a resource (De-Serialize/Serialize) a resource containing an exponential value e.g <value value="5.40e-3"/>
in an Observation resource that the end resource has converted the exponential value to its decimal form e.g "value": 0.00540
.
Is this the expected behaviour?
I had assumed that it should remain in the exponential value format.
Michele Mottini (Apr 14 2020 at 15:11):
I'd say expected: the de-serialization converts those values into .NET decimal
, that then serialize always as plain decimals with no exponentials
Angus Millar (Apr 18 2020 at 11:14):
I can understand why it occurs as described @Michele Mottini but I still question whether it is expected or correct. I would point out that this is the only item I know of that is converted from one form to another in the serialization round trip. My personal view is that should not occur. I would like to preserve the resource in the form it was provided. Perhaps to shine a different light on it, would it be acceptable that observation values were converted up or down the unit scale on serialization round-tripping, say Liters (L) are converted correctly to Milliliters (ml)?
Michele Mottini (Apr 18 2020 at 14:12):
Preserving the format would require de-serializing as string (or to some custom class), that would not be ideal to use the data. De-serializing and then serializing the exact same data does not seem a common use case (why would anyone do it?). Using decimal seems the right call to me.
Johannes Höhn (Apr 20 2020 at 07:19):
For full round-tripping you would also need to keep whitespace (and for xml also comments, xml processing instructions, ...)
Angus Millar (Apr 21 2020 at 05:35):
Comments and white space aren't expected to be retained, good point.
Last updated: Apr 12 2022 at 19:14 UTC