/// <summary> /// <see cref="Byte8"/> は8バイト固定の構造体。 /// 長さは変えれないけど、ヒープアロケーション起きない。 /// </summary> private static Byte8 A(byte x) { var a = new Byte8(); for (int i = 0; i < a.Length; i++) { a[i] = x; } return(a); }
public static Byte8 AddByte4(Byte4 a, Byte4 b, bool c) { var addLow = AddByte2(a.Low, b.Low, c); var addHigh = AddByte2(a.High, b.High, addLow.Sixteen); var emptyByte = new Byte(new Nibble(new Bit2(false, false), new Bit2(false, false)), new Nibble(new Bit2(false, false), new Bit2(false, false))); var emptyByte2 = new Byte2(emptyByte, emptyByte); var high = new Byte4(emptyByte2, addHigh.High); var low = new Byte4(addHigh.Low, addLow.Low); var byte8 = new Byte8(high, low); return(byte8); }
unsafe void testSizeof() { Debug.Log(sizeof(Byte1)); Debug.Log(sizeof(Byte2)); Debug.Log(sizeof(Byte4)); Debug.Log(sizeof(Byte8)); Debug.Log(sizeof(Byte16)); Debug.Log(sizeof(Byte32)); Debug.Log(sizeof(Byte64)); Debug.Log(sizeof(Byte128)); Debug.Log(sizeof(Byte256)); Debug.Log(sizeof(Byte512)); Debug.Log(sizeof(Byte1024)); Debug.Log(sizeof(Byte2048)); Debug.Log(sizeof(Byte4096)); Debug.Log(sizeof(Byte8192)); var a1 = new Byte1[2]; var a2 = new Byte2[2]; var a4 = new Byte4[2]; var a8 = new Byte8[2]; var a16 = new Byte16[2]; var a32 = new Byte32[2]; var a64 = new Byte64[2]; var a128 = new Byte128[2]; var a256 = new Byte256[2]; var a512 = new Byte512[2]; var a1024 = new Byte1024[2]; var a2048 = new Byte2048[2]; var a4096 = new Byte4096[2]; var a8192 = new Byte8192[2]; fixed(Byte1 *ptr = a1) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte2 *ptr = a2) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte4 *ptr = a4) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte8 *ptr = a8) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte16 *ptr = a16) { Debug.Log((int)(ptr + 1) - (int)ptr); }; fixed(Byte32 *ptr = a32) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte64 *ptr = a64) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte128 *ptr = a128) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte256 *ptr = a256) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte512 *ptr = a512) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte1024 *ptr = a1024) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte2048 *ptr = a2048) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte4096 *ptr = a4096) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte8192 *ptr = a8192) { Debug.Log((int)(ptr + 1) - (int)ptr); } fixed(Byte8192 *ptr = a8192) { Byte16 *ptr2 = (Byte16 *)ptr; Debug.Log((int)(ptr2 + 1) - (int)ptr2); } }