/// <returns>String representation of this JSONValue</returns> public override string ToString() { switch (Type) { case JSONValueType.Object: return(Obj.ToString()); case JSONValueType.Array: return(Array.ToString()); case JSONValueType.Boolean: return(Boolean ? "true" : "false"); case JSONValueType.Number: return(Number.ToString()); case JSONValueType.Integer: return(Integer.ToString()); case JSONValueType.Long: return(LongNumber.ToString()); case JSONValueType.String: return("\"" + Str + "\""); case JSONValueType.Null: return("null"); } return("null"); }
protected override void Execute(CodeActivityContext context) { string numberString = string.Empty; if (IntNumber.Expression != null) { numberString = IntNumber.Get(context).ToString(); } else if (LongNumber.Expression != null) { numberString = LongNumber.Get(context).ToString(); } else if (StringNumber.Expression != null) { numberString = StringNumber.Get(context).ToString(); } else { throw new ArgumentException("No input argument was filled."); } string converted = NumberConversor.Convert(numberString); SpelledInNumber.Set(context, converted); }
public LongNumber(LongNumber other) { IsNegative = other.IsNegative; _arr = new int[other._arr.Length]; for (var i = 0; i < _arr.Length; i++) { _arr[i] = other._arr[i]; } }
private List <LongNumber> GetLongNumbers(List <string> stringNumbers) { var longNumbers = new List <LongNumber>(); foreach (var stringNumber in stringNumbers) { longNumbers.Add(LongNumber.FromString(stringNumber)); } return(longNumbers); }
public static void LongFactr(int n) { LongNumber factorial = new LongNumber(1); for (int j = 1; j < n; j++) { factorial.MultOnInt(j + 1); } factorial.Display(); Console.WriteLine($"\nNumber of digits: {factorial.NumberOfDigits()}"); }
public void LongNumber_NumberMultipliedByNumber_GetCorrectNumber(string strNumberOne, string strNumberTwo, string strResult) { // Arrange var numberOne = LongNumber.FromString(strNumberOne); var numberTwo = LongNumber.FromString(strNumberTwo); // Act var result = numberOne * numberTwo; // Assert Assert.Equal(strResult, result.ToString()); }
public void LongNumber_NumberIsComparedWitnNumber_GetCorrectCompare(string strNumberOne, string strNumberTwo, string strResult) { // Arrange var numberOne = LongNumber.FromString(strNumberOne); var numberTwo = LongNumber.FromString(strNumberTwo); // Act var result = LongNumber.AbsCompare(numberOne, numberTwo); // Assert Assert.Equal(strResult, result.ToString()); }
public void LongNumber_NumberSubtractAnotherNumber_GetCorrectNumber(string strNumberOne, string strNumberTwo, string strResult) { // Arrange var numberOne = LongNumber.FromString(strNumberOne); var numberTwo = LongNumber.FromString(strNumberTwo); // Act var result = numberOne - numberTwo; // Assert Assert.Equal(strResult, result.ToString()); }
public void LongNumber_NumberNotEqualAnotherNumber_GetCorrectCompare(string strNumberOne, string strNumberTwo, bool expectedResult) { // Arrange var numberOne = LongNumber.FromString(strNumberOne); var numberTwo = LongNumber.FromString(strNumberTwo); // Act var resultOne = numberOne == numberTwo; var resultTwo = !(numberOne != numberTwo); // Assert Assert.Equal(expectedResult, resultOne); Assert.Equal(expectedResult, resultTwo); }
public string Solve() { var number = new LongNumber(2); for (var i = 3; i < 100; i++) { if (i % 10 == 0) { number = number * (i / 10); } else { number = number * i; } } int sum = number.ToString().Sum(symbol => int.Parse(symbol.ToString(CultureInfo.InvariantCulture))); return sum.ToString(CultureInfo.InvariantCulture); }
public void LongNumber_NumberBiggerThenAnotherNumber_GetCorrectCompare(string strNumberOne, string strNumberTwo, bool expectedResult) { // Arrange var numberOne = LongNumber.FromString(strNumberOne); var numberTwo = LongNumber.FromString(strNumberTwo); // Act var resultOne = numberOne > numberTwo; var resultTwo = !(numberOne < numberTwo) && numberOne != numberTwo; var resultThree = !(numberOne <= numberTwo); var resultFour = numberOne >= numberTwo; // Assert Assert.Equal(expectedResult, resultOne); Assert.Equal(expectedResult, resultTwo); Assert.Equal(expectedResult, resultThree); Assert.Equal(expectedResult, resultFour); }