// Java Rev 1256. // TODO: figure out the roundingModes in this implementation. // TODO: Make this an explicit cast opearator? // TODO: Look at all these conversions. public BigDecimal ToBigDecimal() { BigDecimal numerator = new BigDecimal(this.numerator); BigDecimal denominator = new BigDecimal(this.denominator); return numerator.divide(denominator, 0); }
/** * Calculates the addition of the given real {@link BigDecimal} value to this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to add * @return the calculated {@link BigComplex} result */ public BigComplex add(BigDecimal value) { return(valueOf( re.add(value), im)); }
/** * Calculates the addition of the given real {@code double} value to this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@code double} value to add * @return the calculated {@link BigComplex} result */ public BigComplex add(double value) { return(add(BigDecimal.valueOf(value))); }
/** * Calculates the subtraction of the given real {@link BigDecimal} value from this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to subtract * @return the calculated {@link BigComplex} result */ public BigComplex subtract(BigDecimal value) { return(valueOf( re.subtract(value), im)); }
/** * Calculates the addition of the given real {@link BigDecimal} value to this complex number using the specified {@link MathContext}. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to add * @param mathContext the {@link MathContext} used to calculate the result * @return the calculated {@link BigComplex} result */ public BigComplex add(BigDecimal value, MathContext mathContext) { return(valueOf( re.add(value, mathContext), im)); }
public BigDecimal multiply(BigDecimal e) { return default(BigDecimal); }
//Converts potential sequences into item lists, while flattening to a single dimension private static IEnumerable<Item> GetItems(object obj) { //It it a Node? Node.Node node = obj as Node.Node; if (node != null) { return new[]{node.ANode}; } //Is it a Database? Database database = obj as Database; if(database != null) { return database.Documents.Select(d => d.ANode).Cast<Item>(); } //Is it enumerable (list, array, etc. - but not a string!) //This is recursive and results in flattening any nested sequences IEnumerable enumerable = obj as IEnumerable; if (!(obj is string) && enumerable != null) { return enumerable.Cast<object>().Select(GetItems).SelectMany(x => x); } // Clean up non-.NET values if (obj is Decimal) { obj = new BigDecimal(obj.ToString()); } else if (obj is DateTime) { obj = DatatypeFactory.newInstance().newXMLGregorianCalendar( ((DateTime)obj).ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")); } else if (obj is TimeSpan) { obj = DatatypeFactory.newInstance().newDuration( Convert.ToInt64(((TimeSpan)obj).TotalMilliseconds)); } else if (obj is XmlQualifiedName) { XmlQualifiedName qname = (XmlQualifiedName)obj; obj = new QName(qname.Namespace, qname.Name); } //Get the item return new []{JavaMapping.type(obj).cast(obj, null)}; }
/** * Calculates this complex number divided by the given real {@link BigDecimal} value using the specified {@link MathContext}. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the {@link BigDecimal} value to divide by * @param mathContext the {@link MathContext} used to calculate the result * @return the calculated {@link BigComplex} result */ public BigComplex divide(BigDecimal value, MathContext mathContext) { return(valueOf( re.divide(value, mathContext), im.divide(value, mathContext))); }
/** * Calculates this complex number divided by the given real {@code double} value using the specified {@link MathContext}. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the {@code double} value to divide by * @param mathContext the {@link MathContext} used to calculate the result * @return the calculated {@link BigComplex} result */ public BigComplex divide(double value, MathContext mathContext) { return(divide(BigDecimal.valueOf(value), mathContext)); }
/** * Calculates the multiplication of the given real {@link BigDecimal} value with this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to multiply * @return the calculated {@link BigComplex} result */ public BigComplex multiply(BigDecimal value) { return(valueOf( re.multiply(value), im.multiply(value))); }
/** * Calculates the multiplication of the given real {@code double} value with this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@code double} value to multiply * @return the calculated {@link BigComplex} result */ public BigComplex multiply(double value) { return(multiply(BigDecimal.valueOf(value))); }
public BigComplex(BigDecimal re, BigDecimal im) { this.re = re; this.im = im; }
/** * Calculates the multiplication of the given real {@link BigDecimal} value with this complex number using the specified {@link MathContext}. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to multiply * @param mathContext the {@link MathContext} used to calculate the result * @return the calculated {@link BigComplex} result */ public BigComplex multiply(BigDecimal value, MathContext mathContext) { return(valueOf( re.multiply(value, mathContext), im.multiply(value, mathContext))); }
/** * Calculates the subtraction of the given real {@code double} value from this complex number. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@code double} value to subtract * @return the calculated {@link BigComplex} result */ public BigComplex subtract(double value) { return(subtract(BigDecimal.valueOf(value))); }
public BigDecimal add(BigDecimal e) { return default(BigDecimal); }
/** * Returns a complex number with the specified real {@code double} part. * * @param real the real {@code double} part * @return the complex number */ public static BigComplex valueOf(double real) { return(valueOf(BigDecimal.valueOf(real), BigDecimal.ZERO)); }
public BigDecimal divide(BigDecimal e, int scale, int mode) { return default(BigDecimal); }
/** * Returns a complex number with the specified real and imaginary {@code double} parts. * * @param real the real {@code double} part * @param imaginary the imaginary {@code double} part * @return the complex number */ public static BigComplex valueOf(double real, double imaginary) { return(valueOf(BigDecimal.valueOf(real), BigDecimal.valueOf(imaginary))); }
public BigDecimal subtract(BigDecimal e) { return default(BigDecimal); }
public static BigComplex valueOfPolar(double radius, double angle, MathContext mathContext) { return(valueOfPolar(BigDecimal.valueOf(radius), BigDecimal.valueOf(angle), mathContext)); }
public WrappedBigDecimal(BigDecimal e) { Value = e; }
/** * Calculates the subtraction of the given real {@link BigDecimal} value from this complex number using the specified {@link MathContext}. * * <p>This methods <strong>does not</strong> modify this instance.</p> * * @param value the real {@link BigDecimal} value to add * @param mathContext the {@link MathContext} used to calculate the result * @return the calculated {@link BigComplex} result */ public BigComplex subtract(BigDecimal value, MathContext mathContext) { return(valueOf( re.subtract(value, mathContext), im)); }