Closed dexX7 closed 9 years ago
Added the PUSH_BACK_BYTE
makros which seem very related to the swapByteOrderN functions.
As a side note: whenever you can, I suggest to use exact width types such as uint8_t
, uint16_t
, uint32_t
, uint64_t
. It's worth to look into stdint.h
to see which underlying type is used and this is very relevant for 32 bit systems. Especially when it comes to the use of PUSH_BACK_BYTE
.
@m21: Merge, adjust or close?
Not the best time sorry, but please don't close it. I very much like all the auto-tests. They are very useful for us going cross-platform.
Again, because of generous commenting and inclusion of tests, I support this being merged.
I tested swapByteOrder and noticed swapByteOrder(swapByteOrder(x)) != swapByteOrder(x). This sort of implies correct ordered data might be reordered, even if this produces wrong data. I'm not sure under which circumstances this could happen (obvious case of nested functions aside), but I guess you should be aware of this (@m21).
That said, there is htobe16, htobe32 and htobe64 which might be an alternative?
Regarding the downsides of (old) rounduint64 see #178. Most significantly: it doesn't clip anymore and numbers >= 2147483648.0 are accepted. Negative numbers have a similar behavior like positive numbers, whereby this wasn't used at all until now: