Class ComplexNumber

  • All Implemented Interfaces:
    java.io.Serializable

    public class ComplexNumber
    extends java.lang.Number
    A complex number.
    Author:
    Matthias Thimm
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ComplexNumber​(double real, double imag)
      Constructs a new complex number with the given real and imaginary parts.
    • Method Summary

      Modifier and Type Method Description
      double doubleValue()  
      float floatValue()  
      double getImagPart()
      Returns the imaginary part of this complex number.
      double getRealPart()
      Returns the real part of this complex number.
      int intValue()  
      long longValue()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Number

        byteValue, shortValue
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ComplexNumber

        public ComplexNumber​(double real,
                             double imag)
        Constructs a new complex number with the given real and imaginary parts.
        Parameters:
        real - the real part.
        imag - the imaginary part.
    • Method Detail

      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class java.lang.Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class java.lang.Number
      • intValue

        public int intValue()
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class java.lang.Number
      • getRealPart

        public double getRealPart()
        Returns the real part of this complex number.
        Returns:
        the real part of this complex number.
      • getImagPart

        public double getImagPart()
        Returns the imaginary part of this complex number.
        Returns:
        the imaginary part of this complex number.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object