public void TestInitialize() { bin2 = new BinaryDigit("1010"); bin3 = new BinaryDigit("1010", ','); bin4 = new BinaryDigit("1111,00100000110001001001101110100101111000110101001111111"); bin5 = new BinaryDigit("1111,00100000110001001001101110100101111000110101001111111", ','); bin6 = new BinaryDigit(null); bin7 = new BinaryDigit(string.Empty); bin8 = new BinaryDigit(" "); bin9 = new BinaryDigit("1111,00100000110001001001101110100101111000110101001111111", '.'); }
public static char ToChar(this BinaryDigit src) { if (src == BinaryDigit.Zed) { return(AsciDigits.A0); } else if (src == BinaryDigit.One) { return(AsciDigits.A1); } else { return(MathSym.EmptySet); } }
static void Main(string[] args) { BinaryDigit bin = new BinaryDigit("101,11", ','); GetDecimal(bin); //5,75 bin.SetValue("1110,0101"); GetOctal(bin); //16,24 bin.SetValue("1111010,0111111"); GetHexadecimal(bin); //7A,7E DecimalDigit dec = new DecimalDigit(11); GetBinary(dec); //1011 dec.SetValue("0"); GetBinary(dec); //00 dec.SetValue("0,378"); GetBinary(dec); //110000,101 dec.SetValue("48,378"); GetBinary(dec); //110000.01100000110 dec.SetValue("0,7"); GetHexadecimal(dec); //B333 dec.SetValue("0,6"); GetOctal(dec); //0,463 OctalDigit oct1 = new OctalDigit("57,24"); OctalDigit oct2 = new OctalDigit("57,24", ','); GetOctal(oct1); // 57,24 GetOctal(oct2); // 57,24 GetDecimal(oct1); // 47,3125 GetDecimal(oct2); // 47,3125 oct1.SetValue("16,24"); oct2.SetValue("16,24"); GetBinary(oct1); // 1110,0101 GetBinary(oct2); // 1110,0101 oct1.SetValue("46,667"); oct2.SetValue("45,123"); GetHexadecimal(oct1); // 26,DB8 GetHexadecimal(oct2); // 25,298 HexadecimalDigit hex1 = new HexadecimalDigit("26,DB8"); HexadecimalDigit hex2 = new HexadecimalDigit("25,298", ','); GetBinary(hex1); //100110.110110111 GetBinary(hex2); //100101.001010011 GetDecimal(hex1); //38.857421875 GetDecimal(hex2); //37.162109375 GetOctal(hex1); //46,667 GetOctal(hex2); //45,123 GetHexadecimal(hex1); //26,DB8 GetHexadecimal(hex2); //25,298 Console.ReadLine(); }