PerformanceStubs icon indicating copy to clipboard operation
PerformanceStubs copied to clipboard

Make `unsafe` handle big endian

Open patridge opened this issue 9 years ago • 0 comments

[via comment from Stack Overflow question]

The unsafe byte->string variant to handle when BitConverter.IsLittleEndian == false.

Comment indicates that the original CodesInChaos source material handles this situation, which appears true.

if(BitConverter.IsLittleEndian)
    result[i] = ((uint)s[0]) + ((uint)s[1] << 16);
else
    result[i] = ((uint)s[1]) + ((uint)s[0] << 16);

patridge avatar Aug 28 '15 16:08 patridge