Complex data type

Complex data type

Some programming languages provide a complex data type for complex number storage and arithmetic as a built-in (primitive) data type.

In some programming environments the term complex data type (in contrast to primitive data types) is a synonym to the composite data type.[1][2]

Contents

Complex number arithmetic

A complex variable or value is usually represented as a pair of floating point numbers. Languages that support a complex data type usually provide special syntax for building such values, and extend the basic arithmetic operations ('+', '−', '×', '/') to act on them. These operations are usually translated by the compiler into a sequence of floating-point machine instructions or into library calls. Those languages may also provide support for other operations, such as formatting, equality testing, etc. As in mathematics, those languages often interpret a floating-point value as equivalent to a complex value with a zero imaginary part.

Language support

  • The FORTRAN's type COMPLEX
  • The C99 standard of the C programming language includes complex data types and complex math functions in the standard library header <complex.h>
  • The C++ standard library provides a complex templated class as well as complex math functions in the header <complex>
  • The Perl core module Math::Complex provides support for complex numbers
  • Python support complex numbers built-in with the type complex. Imaginary number literals can be specified by appending a "j". Complex math functions are provided in the standard library module cmath [3]
  • Ruby provides a Complex class in the standard library module complex
  • OCaml supports complex numbers with the standard library module Complex
  • Haskell supports complex numbers with the standard library module Complex
  • The Apache Commons Math library provides complex numbers for Java with its Complex class
  • Common Lisp: The ANSI Common Lisp standard supports complex numbers of floats and arbitrary precision integers. Its basic mathematical functions are defined for complex numbers, where applicable. For example the square root of -1 is a complex number:
 ? (sqrt -1)
#C(0 1)            ; the result of (sqrt -1)
  • Scheme: Complex numbers and functions (e.g. sin) are included in the language specification. Their implementation is however optional in the R5RS standard, while in R6RS is mandatory.
  • The .NET Framework provides System.Numerics.Complex since version 4.0.

History

The COMPLEX data type was provided in FORTRAN IV.[4]


References

  1. ^ IBM Informix Database Design and Implementation Guide
  2. ^ Flash 8 Documentation[dead link]
  3. ^ Python v2.6.5 documentation
  4. ^ A guide to Fortran IV programming Daniel D. McCracken - 1972 - 288 pages. "The capability provided by Fortran complex operations is a great savings in programming effort in certain problems. "

Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Data type — For other uses, see Data type (disambiguation). In computer programming, a data type is a classification identifying one of various types of data, such as floating point, integer, or Boolean, that determines the possible values for that type; the …   Wikipedia

  • Algebraic data type — In computer programming, particularly functional programming and type theory, an algebraic data type (sometimes also called a variant type[1]) is a datatype each of whose values is data from other datatypes wrapped in one of the constructors of… …   Wikipedia

  • Composite data type — In computer science, a composite data type is any data type which can be constructed in a program using its programming language s primitive data types and other composite types. The act of constructing a composite type is known as composition.… …   Wikipedia

  • Array data type — Not to be confused with Array data structure. In computer science, an array type is a data type that is meant to describe a collection of elements (values or variables), each selected by one or more indices that can be computed at run time by the …   Wikipedia

  • Opaque data type — In computer science, an opaque data type is a user defined data type used like built in data type. It is incompletely defined in an interface, so that ordinary client programs can only manipulate data of that type by calling procedures that have… …   Wikipedia

  • Abstract data type — In computing, an abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. Such a data type is abstract in the sense that it is independent of various concrete implementations. The… …   Wikipedia

  • Decimal data type — Some programming languages provide a built in (primitive) or library decimal data type to represent non repeating decimal fractions like 0.3 and 1.17 without rounding, and to do arithmetic on them. Examples are the decimal.Decimal type of Python …   Wikipedia

  • Type system — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • Data structure alignment — is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding. When a modern computer reads from or writes to a memory address, it will do this in word sized …   Wikipedia

  • Type inference — Type inference, or implicit typing, refers to the ability to deduce automatically the type of a value in a programming language. It is a feature present in some strongly statically typed languages. It is often characteristic of but not limited to …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”