/// <summary> /// Mul operator *: Multiply two values. /// </summary> /// <param name="left">A value to multiply with</param> /// <param name="right">A value to multiply</param> /// <returns>(left.value * right.value, [Normalised(left.scale right.scale)])</returns> public static LongST Mul(LongST left, LongST right) { var result = new LongST(left.Value * right.Value, left.Scale); result.Append(right.Scale); return(result); }
/// <summary> /// Assign: assign a new value to this instance /// </summary> /// <param name="value">The new value</param> /// <exception cref="ArgumentOutOfRangeException">Scales of this and the other must be (syntactical) equivalents</exception> /// <remarks>It is not possible to override operator=()</remarks> public void Assign(LongST other) { if (ReferenceEquals(this, other)) { return; } base.Assign(other); Value = other.Value; }
/// <summary> /// Sub operator -: Subtract two values with equal scale. /// </summary> /// <param name="left">A value to subtract from</param> /// <param name="right">A value to subtract</param> /// <exception cref="ArgumentOutOfRangeException">left scale is not (semantical) equal to right scale.</exception> /// <returns>(left.value - right.value, [scale])</returns> public static LongST Sub(LongST left, LongST right) { if (left.Scale != right.Scale) { var msg = $"not supported: {left.Scale} - {right.Scale}"; //log.Debug(msg); throw new ArgumentOutOfRangeException(msg); } return(new LongST(left.Value - right.Value, left.Scale)); }
/// <summary> /// Div operator /: Divide two values. /// </summary> /// <param name="left">A value to divide to</param> /// <param name="right">A value to divide with</param> /// <returns>(left.value / right.value, [Normalised(left.scale, right.scale^-1)])</returns> public static LongST Div(LongST left, LongST right) { if (right.Value == 0.0) { throw new DivideByZeroException($"{left} / {right} "); } var result = new LongST(left.Value / right.Value, left.Scale); result.Append(right.Scale, reciproce: true); return(result); }
/// <summary> /// .ctor: copy constructor. /// </summary> /// <param name="other">Data to copy.</param> public LongST(LongST other) : base(other.Scale) { Value = other.value; }