/* Usuwa czesc dziesietna (ulamkowa) z liczby */ public void CutDecimalPortion() { int resultIndex = CurrentEquationState.IndexOf(','); if (-1 != resultIndex) { CurrentEquationState = CurrentEquationState.Substring(0, resultIndex); } }
/* Zmienia wyswietlana liczbe (w dowolnym systemie liczbowym w zaleznosci * od wybranej dlugosci slowa. Na wejsciu przyjmuje liczbe w systemie * dziesietnym. */ public void ChangeNumberBaseSystem(string decNumber, NumberBaseSystem fromBase, NumberBaseSystem goalBase) { switch (CurrentWordLength) { case WordLengths.QWORD: CurrentEquationState = Convert.ToString(Convert.ToInt64((long.Parse(decNumber)).ToString(), (int)fromBase), (int)goalBase).ToUpper(); break; case WordLengths.DWORD: CurrentEquationState = Convert.ToString(Convert.ToInt32(((int)(long.Parse(decNumber))).ToString(), (int)fromBase), (int)goalBase).ToUpper(); break; case WordLengths.WORD: CurrentEquationState = Convert.ToString(Convert.ToInt16(((short)(long.Parse(decNumber))).ToString(), (int)fromBase), (int)goalBase).ToUpper(); break; case WordLengths.BYTE: CurrentEquationState = Convert.ToString(Convert.ToSByte(((sbyte)(long.Parse(decNumber))).ToString(), (int)fromBase), (int)goalBase).ToUpper(); switch (CurrentNumberBaseSystem) { case NumberBaseSystem.Binary: if (CurrentEquationState.Length > 8) { CurrentEquationState = CurrentEquationState.Substring(CurrentEquationState.Length - 8); } break; case NumberBaseSystem.Decimal: break; case NumberBaseSystem.Hexadecimal: if (CurrentEquationState.Length > 2) { CurrentEquationState = CurrentEquationState.Substring(CurrentEquationState.Length - 2); } break; case NumberBaseSystem.Octal: break; } break; } UpdateDisplay(this, eUpdateArgs); }