using System;
public class Program
{
static ulong Expand(byte b)
ulong shift = 0x0000040810204081ul; // bits set: 0, 7, 14, 21, 28, 35, 42
ulong mask = 0x0001010101010101ul; // bits set: 0, 8, 16, 24, 32, 40, 48
return (ulong)(b & 127) * shift & mask | (ulong)(b & 128) << 49;
}
public static void Main()
var i = Expand(255);
Console.WriteLine("{0:X4}", i);