public string Print() { LongNumber temp = new LongNumber(maxDigits); temp.Assign(this); StringBuilder sb = new StringBuilder(); sb.Append(temp.number[0]); sb.Append(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator); int digitCount = 0; while (digitCount < maxDigits) { temp.number[0] = 0; temp.Multiply(100000); sb.AppendFormat("{0:D5}", temp.number[0]); digitCount += 5; } string result = sb.ToString(); int rest = maxDigits % 5; if (rest != 0) { result = result.Substring(0, result.Length - (5 - rest)); } return(result); }
public async Task ArcTan(UInt32 multiplicand, UInt32 reciprocal, CancellationToken cancellationToken = default) { LongNumber X = new LongNumber(maxDigits, multiplicand); X.Divide(reciprocal); reciprocal *= reciprocal; this.Assign(X); LongNumber term = new LongNumber(maxDigits); UInt32 divisor = 1; bool subtractTerm = true; while (true) { cancellationToken.ThrowIfCancellationRequested(); X.Divide(reciprocal); term.Assign(X); divisor += 2; term.Divide(divisor); if (term.IsZero()) { break; } if (subtractTerm) { this.Subtract(term); } else { this.Add(term); } subtractTerm = !subtractTerm; } }