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 for the composite data type.^{ [1] }^{ [2] }

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.

- The FORTRAN COMPLEX type
- 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`

template class as well as complex-math functions in the`<complex>`

header. - The Go programming language has built-in types
`complex64`

(each component is 32-bit float) and`complex128`

(each component is 64-bit float). - The Perl core module Math::Complex provides support for complex numbers.
- Python provides the built-in
`complex`

type. 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 Data.Complex (previously called Complex).
- Mercury provides complex numbers with full operator overloading support in the extras distribution, using libcomplex_numbers.
- Java does not have a standard complex number class, but there exist a number of incompatible free implementations of a complex number class:
- The Apache Commons Math library provides complex numbers for Java with its Complex class.
- The JScience library has a Complex number class.
- The JAS library allows the use of complex numbers.
- Netlib has a complex number class for Java.
- javafastcomplex also adds complex number support for Java
- jcomplexnumber is a project on implementation of complex number in Java.
- JLinAlg includes complex numbers with arbitrary precision.

- Common Lisp: The ANSI Common Lisp standard supports complex numbers of floats, rationals 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(01); 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.
- The smart BASIC for iOS naturally supports complex numbers in notation
**a + bi**. Any variable, math operation or function can accept both real and complex numbers as arguments and return real or complex numbers depending on result. For example the square root of -4 is a complex number:PRINT SQRT(-4) 2i

The `COMPLEX`

data type was provided in FORTRAN IV.^{ [4] }

**Common Lisp** (**CL**) is a dialect of the Lisp programming language, published in ANSI standard document *ANSI INCITS 226-1994 (S20018)*. The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived from the ANSI Common Lisp standard.

**Fortran** is a general-purpose, compiled imperative programming language that is especially suited to numeric computation and scientific computing.

**Double-precision floating-point format** is a computer number format, usually occupying 64 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

In computer science, **primitive data type** is either of the following:

In computer science, **conditionals** are programming language commands for handling decisions. Specifically, conditionals perform different computations or actions depending on whether a programmer-defined boolean *condition* evaluates to true or false. In terms of control flow, the decision is always achieved by selectively altering the control flow based on some condition.

In computer science, **type safety** is the extent to which a programming language discourages or prevents **type errors**. A type error is erroneous or undesirable program behaviour caused by a discrepancy between differing data types for the program's constants, variables, and methods (functions), e.g., treating an integer (**int**) as a floating-point number (**float**). Type safety is sometimes alternatively considered to be a property of a computer program rather than the language in which that program is written; that is, some languages have type-safe facilities that can be circumvented by programmers who adopt practices that exhibit poor type safety. The formal type-theoretic definition of type safety is considerably stronger than what is understood by most programmers.

**C99** is an informal name for **ISO/IEC 9899:1999**, a past version of the C programming language standard. It extends the previous version (C90) with new features for the language and the standard library, and helps implementations make better use of available computer hardware, such as IEEE 754-1985 floating-point arithmetic, and compiler technology. The C11 version of the C programming language standard, published in 2011, replaces C99.

The **GNU Scientific Library** is a software library for numerical computations in applied mathematics and science. The GSL is written in C; wrappers are available for other programming languages. The GSL is part of the GNU Project and is distributed under the GNU General Public License.

In computer science and numerical analysis, **unit in the last place **or** unit of least precision** (**ULP**) is the spacing between two consecutive floating-point numbers, i.e., the value the least significant digit represents if it is 1. It is used as a measure of accuracy in numeric calculations.

**Signed zero** is zero with an associated sign. In ordinary arithmetic, the number 0 does not have a sign, so that −0, +0 and 0 are identical. However, in computing, some number representations allow for the existence of two zeros, often denoted by **−0** and **+0**, regarded as equal by the numerical comparison operations but with possible different behaviors in particular operations. This occurs in the *sign and magnitude* and *ones' complement* signed number representations for integers, and in most floating-point number representations. The number 0 is usually encoded as +0, but can be represented by either +0 or −0.

**C mathematical operations** are a group of functions in the standard library of the C programming language implementing basic mathematical functions. All functions use floating-point numbers in one manner or another. Different C standards provide different, albeit backwards-compatible, sets of functions. Most of these functions are also available in the C++ standard library, though in different headers.

**Extended precision** refers to floating-point number formats that provide greater precision than the basic floating-point formats. Extended precision formats support a basic format by minimizing roundoff and overflow errors in intermediate values of expressions on the base format. In contrast to *extended precision*, arbitrary-precision arithmetic refers to implementations of much larger numeric types using special software.

In computer science, a **three-way comparison** takes two values A and B belonging to a type with a total order and determines whether A < B, A = B, or A > B in a single operation, in accordance with the mathematical law of trichotomy.

This article compares a large number of programming languages by tabulating their data types, their expression, statement, and declaration syntax, and some common operating-system interfaces.

**Hypot** is a mathematical function defined to calculate the length of the hypotenuse of a right-angle triangle. It was designed to avoid errors arising due to limited-precision calculations performed on computers.

Some programming languages provide a built-in (primitive) **rational data type** to represent rational numbers like 1/3 and -11/17 without rounding, and to do arithmetic on them. Examples are the `ratio`

type of Common Lisp, and analogous types provided by most languages for algebraic computation, such as Mathematica and Maple. Many languages that do not have a built-in rational type still provide it as a library-defined type.

In computing, **quadruple precision** is a binary floating point–based computer number format that occupies 16 bytes with precision at least twice the 53-bit double precision.

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, and analogous types provided by other languages.

- ↑ IBM Informix Database Design and Implementation Guide
- ↑ "Flash 8 Documentation". Archived from the original on 2009-04-27. Retrieved 2009-05-11.
- ↑ Python v2.6.5 documentation
- ↑ 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. "

This page is based on this Wikipedia article

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.

Text is available under the CC BY-SA 4.0 license; additional terms may apply.

Images, videos and audio are available under their respective licenses.