Em ter?a-feira, 20 de dezembro de 2016, ?s 21:02:25 PST, Pawel Winogrodzki via 
iotivity-dev escreveu:
> Hi all,
> 
> I've noticed that OCRepPayloadGetPropDouble() inside
> resource/csdk/stack/src/ocpayload.c is implemented to work with payload
> values of type OCREP_PROP_INT (in addition to OCREP_PROP_DOUBLE), which are
> defined as "int64_t". That causes a int64_t->double cast, so there's a
> possibility of data loss, since "double" is not precise enough to represent
> higher values of "int64_t".
> 
> Is that the expected behavior? I haven't seen any tests for this scenario,
> nor found any usage of the API, except for one occurrence inside
> resource/csdk/stack/test/cbortests.cpp.

Yes and there's no data loss. Since all OCF data models use JSON, not CBOR, 
it's simply impossible by construction for the models to contain data that 
would cause data loss there.

The data loss, if any, occurred when the application converted its internal 
data to the OCF data model in JSON, before the conversion to CBOR.

(That's theoretical view; in practice, we skip the JSON step and convert from 
application data directly to CBOR)

This may change once OCF adopts the Swagger specification for further refining 
data format in JSON, which may allow us to transport integral beyond the range 
of double.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Reply via email to