BitField.BitField.Create C# (CSharp) Method

Create() public static method

1 びっとのビットフィールドを作成。
public static Create ( bool b ) : BitField
b bool ビットの真理値
return BitField
		public static BitField Create(bool b)
		{
			return new BitFieldImmediate(0, 0, b ? 1UL : 0UL);
		}

Same methods

BitField::Create ( int m, int l ) : BitField
BitField::Create ( int m, int l, ulong val ) : BitField

Usage Example

コード例 #1
0
        /// <summary>
        /// Binary → BCD 変換
        /// </summary>
        /// <param name="bin">変換元</param>
        /// <param name="overflow">オーバーフローが起きたらtrueにセットされる。</param>
        /// <returns>変換結果</returns>
        public static BitField BinToBcd(BitField bin, out bool overflow)
        {
            BitField bcd = BitField.Concat(BitField.Create(30, 0, 0), bin);

            overflow = false;
            for (int i = 0; i < 30; ++i)
            {
                BitField a0      = BinToBcdAddIn(bcd[61, 58]);
                BitField a1      = BinToBcdAddIn(bcd[57, 54]);
                BitField a2      = BinToBcdAddIn(bcd[53, 50]);
                BitField a3      = BinToBcdAddIn(bcd[49, 46]);
                BitField a4      = BinToBcdAddIn(bcd[45, 42]);
                BitField a5      = BinToBcdAddIn(bcd[41, 38]);
                BitField a6      = BinToBcdAddIn(bcd[37, 34]);
                BitField a7      = BinToBcdAddIn(bcd[33, 30]);
                BitField add_in  = BitField.Concat(a0, a1, a2, a3, a4, a5, a6, a7);
                BitField add_out = bcd[61, 30] + add_in;


                bcd.Assign(BitField.Concat(add_out, bcd[29, 0], BitField.Create(0, 0, 0)));
                overflow |= add_out[add_out.Msb];
            }

            return(bcd[61, 30]);
        }
All Usage Examples Of BitField.BitField::Create