MCPcopy Create free account
hub / github.com/Tracktion/choc / zigzagEncode

Function zigzagEncode

choc/memory/choc_VariableLengthEncoding.h:131–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130template <typename IntegerType>
131IntegerType zigzagEncode (IntegerType n)
132{
133 auto un = static_cast<typename std::make_unsigned<IntegerType>::type> (n);
134 auto sn = static_cast<typename std::make_signed<IntegerType>::type> (n);
135 return static_cast<IntegerType> ((sn >> (sizeof (IntegerType) * 8 - 1)) ^ static_cast<IntegerType> (un << 1));
136}
137
138template <typename IntegerType>
139IntegerType zigzagDecode (IntegerType n)

Callers 1

testPlatformFunction · 0.85

Calls

no outgoing calls

Tested by 1

testPlatformFunction · 0.68