-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/33194/#review80147
-----------------------------------------------------------
I still really don't like the code changing depending on the endianness of the
platform - Wouldn't it just be better to read the value as either a 4 or 8 byte
int (uint32_t or uint64_t) and then just use a union to read the value as float
or double?
ie
union {double d; uint64_t i} converter64;
union {float f; uint32_t i} converter32;
converter64.i = bytevalue;
return converter64.d;
etc.
- It's a bit of a hack but it is pretty portable as the alignment is required
by the standard (I'm pretty sure)
Then we can just get rid of copyConvert & convertIfRequired which would make me
happier.
trunk/qpid/cpp/src/tests/FieldValue.cpp
<https://reviews.apache.org/r/33194/#comment129917>
Why shouldn't floats convert to ints? (unless they outside the
representable range)
- Andrew Stitcher
On April 14, 2015, 9:57 p.m., Alan Conway wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33194/
> -----------------------------------------------------------
>
> (Updated April 14, 2015, 9:57 p.m.)
>
>
> Review request for qpid and Andrew Stitcher.
>
>
> Repository: qpid
>
>
> Description
> -------
>
> Previous code would incorrectly convert between float and int types producing
> nonsense values,
> and would not allow legal conversions between float and double types.
>
> Created FixedWidthIntValue and FixedWidthFloatValue template subclasses to
> correctly
> handle conversions. Enabled FieldValue unit tests for float conversions.
>
>
> Diffs
> -----
>
> trunk/qpid/cpp/src/qpid/framing/Endian.h 1673017
> trunk/qpid/cpp/src/qpid/framing/Endian.cpp 1673017
> trunk/qpid/cpp/src/qpid/framing/FieldValue.h 1673017
> trunk/qpid/cpp/src/qpid/framing/FieldValue.cpp 1673017
> trunk/qpid/cpp/src/tests/FieldTable.cpp 1673017
> trunk/qpid/cpp/src/tests/FieldValue.cpp 1673017
>
> Diff: https://reviews.apache.org/r/33194/diff/
>
>
> Testing
> -------
>
> Added unit tests for float conversions.
>
>
> Thanks,
>
> Alan Conway
>
>