public static RomanNumeral Sqrt(RomanNumeral a) { int sqrtResult = (int)Math.Sqrt(a.decimalNumber); if (sqrtResult * sqrtResult == a.decimalNumber) { return(new RomanNumeral(RNConverter.ConvertFromIntToRomanNumeral((int)Math.Sqrt(a.decimalNumber)))); } else { throw new Exception($"{a.decimalNumber} doesn't have an integer root!"); } }
private static void ChooseOperator(string word, ref Stack <int> numbers) { RomanNumeral number1 = new RomanNumeral(numbers.Peek()); numbers.Pop(); if (word != "√") { RomanNumeral number2 = new RomanNumeral(numbers.Peek()); numbers.Pop(); switch (word) { case "+": numbers.Push((number2 + number1).decimalNumber); break; case "-": numbers.Push((number2 - number1).decimalNumber); break; case "*": numbers.Push((number2 * number1).decimalNumber); break; case "/": numbers.Push((number2 / number1).decimalNumber); break; case "%": numbers.Push((number2 % number1).decimalNumber); break; case "^": numbers.Push((number2 ^ number1).decimalNumber); break; } } else { numbers.Push(RomanNumeral.Sqrt(number1).decimalNumber); } }
public RomanNumeral(RomanNumeral romanNumeral) { this.decimalNumber = romanNumeral.decimalNumber; this.romanNumeralStr = romanNumeral.romanNumeralStr; }