/// <summary> /// Visits a <see cref="MagnitudeExpression" />. /// </summary> /// <param name="magnitudeExpression">The magnitude expression.</param> /// <param name="notationParameters">The notation parameters.</param> /// <param name="notationVariables">The notation variables.</param> public void Magnitude( MagnitudeExpression magnitudeExpression, NotationParameters notationParameters, NotationVariables notationVariables) { var requestPrecendence = notationVariables.RequestPrecedence; var stringBuilder = notationParameters.StringBuilder; this.HandleLeftPrecedence(requestPrecendence, stringBuilder); magnitudeExpression.Lhs.Visit(this, notationParameters, new NotationVariables(true, true)); var constant = magnitudeExpression.Rhs.Constant.ToString(notationParameters.FormatProvider); switch (this.notationOptions.MagnitudeFormat) { case MagnitudeFormat.UseAboveLetter: if (magnitudeExpression.Lhs is MagnitudeExpression) { stringBuilder.Append(Constants.Power); } stringBuilder.Append(CharacterConverter.ToExponentNotation(constant)); break; default: stringBuilder.Append(Constants.Power); stringBuilder.Append(constant); break; } this.HandleRightPrecedence(requestPrecendence, stringBuilder); }
/// <summary> /// Returns a <see cref="string" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="string" /> that represents this instance. /// </returns> public override string ToString() { return(this.UnitExpression + CharacterConverter.ToExponentNotation(this.Exponent.ToString(CultureInfo.CurrentCulture))); }