public override TANumber Subtract(TANumber otherNumber)
        {
            TPNumber realPart = new TPNumber(this.realPart.ValueNumber - (otherNumber as TCompNumber).realPart.ValueNumber,
                                             this.realPart.RadixNumber, this.realPart.ErrorLengthNumber);
            TPNumber imagePart = new TPNumber(this.imagePart.ValueNumber - (otherNumber as TCompNumber).imagePart.ValueNumber,
                                              this.imagePart.RadixNumber, this.imagePart.ErrorLengthNumber);

            return(new TCompNumber(realPart, imagePart));
        }
Example #2
0
        public override TANumber Divide(TANumber otherNumber)
        {
            TPNumber numerator = new TPNumber(this.numerator.ValueNumber * (otherNumber as TFractNumber).denominator.ValueNumber,
                                              this.numerator.RadixNumber, this.numerator.ErrorLengthNumber);
            TPNumber denominator = new TPNumber(this.denominator.ValueNumber * (otherNumber as TFractNumber).numerator.ValueNumber,
                                                this.denominator.RadixNumber, this.denominator.ErrorLengthNumber);

            return(new TFractNumber(numerator, denominator));
        }
        public override TANumber Divide(TANumber otherNumber)
        {
            TPNumber realPart = new TPNumber(((this.realPart.ValueNumber * (otherNumber as TCompNumber).realPart.ValueNumber + this.imagePart.ValueNumber * (otherNumber as TCompNumber).imagePart.ValueNumber)) /
                                             ((otherNumber as TCompNumber).realPart.ValueNumber * (otherNumber as TCompNumber).realPart.ValueNumber + (otherNumber as TCompNumber).imagePart.ValueNumber * (otherNumber as TCompNumber).imagePart.ValueNumber),
                                             this.realPart.RadixNumber, this.realPart.ErrorLengthNumber);
            TPNumber imagePart = new TPNumber(((this.imagePart.ValueNumber * (otherNumber as TCompNumber).realPart.ValueNumber - this.realPart.ValueNumber * (otherNumber as TCompNumber).imagePart.ValueNumber)) /
                                              ((otherNumber as TCompNumber).realPart.ValueNumber * (otherNumber as TCompNumber).realPart.ValueNumber + (otherNumber as TCompNumber).imagePart.ValueNumber * (otherNumber as TCompNumber).imagePart.ValueNumber),
                                              this.imagePart.RadixNumber, this.imagePart.ErrorLengthNumber);

            return(new TCompNumber(realPart, imagePart));
        }
        public override TANumber Divide(TANumber otherNumber)
        {
            TPNumber result = new TPNumber();

            result.errorLength = otherNumber.ErrorLengthNumber + errorLength;
            result.value       = Convert.ToString(ConverterFrom10.Convert(ConverterTo10.Convert(ValueString, radix) /
                                                                          ConverterTo10.Convert(otherNumber.ValueString, otherNumber.RadixNumber), otherNumber.RadixNumber, result.errorLength));
            result.radix = otherNumber.RadixNumber;

            return(result);
        }
        public override TANumber Add(TANumber otherNumber)
        {
            TPNumber result = new TPNumber();

            result.errorLength = otherNumber.ErrorLengthNumber + errorLength;
            double sum = ConverterTo10.Convert(otherNumber.ValueString, otherNumber.RadixNumber) +
                         ConverterTo10.Convert(ValueString, radix);

            result.value       = Convert.ToString(ConverterFrom10.Convert(sum, otherNumber.RadixNumber, result.errorLength));
            result.radix       = otherNumber.RadixNumber;
            result.errorLength = Math.Max(otherNumber.ErrorLengthNumber, errorLength);

            return(result);
        }
 public override bool Equals(TANumber other)
 {
     return((other as TCompNumber).realPart.Equals(this.realPart) && (other as TCompNumber).imagePart.Equals(this.imagePart));
 }
 public override bool Equals(TANumber other)
 {
     return(value == (other as TPNumber).value && radix == (other as TPNumber).radix);
 }
Example #8
0
 public override bool Equals(TANumber other)
 {
     return((other as TFractNumber).numerator.Equals(this.numerator) && (other as TFractNumber).denominator.Equals(this.denominator));
 }