HOME

TheInfoList



OR:

Some
programming languages A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
provide a complex data type for
complex number In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the fo ...
storage and arithmetic as a built-in (primitive) data type. In some programming environments the term ''complex data type'' (in contrast to
primitive data type In computer science, primitive data types are a set of basic data types from which all other data types are constructed. Specifically it often refers to the limited set of data representations in use by a particular processor, which all compiled pr ...
s) is a synonym for the
composite data type In computer science, a composite data type or compound data type is any data type which can be constructed in a program using the programming language's primitive data types and other composite types. It is sometimes called a structure or aggreg ...
.


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 In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
into a sequence of floating-point
machine instruction In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very ...
s or into
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
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 COMPLEX type. * The
C99 C99 (previously known as C9X) 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 impl ...
standard of the C programming language includes complex data types and complex-math functions in the standard library header < complex.h>. * The
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
standard library provides a complex template class as well as complex-math functions in the 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 Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
core module provides support for complex numbers. *
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
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. *
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
provides a class in the standard library module . * OCaml supports complex numbers with the standard library module . *
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
supports complex numbers with the standard library module (previously called ). * Mercury provides complex numbers with full operator overloading support in the extras distribution, using . *
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
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 class. ** Th
JScience
library has a number class. ** Th
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(0 1) ; the result of (sqrt -1) *
Scheme A scheme is a systematic plan for the implementation of a certain idea. Scheme or schemer may refer to: Arts and entertainment * ''The Scheme'' (TV series), a BBC Scotland documentary series * The Scheme (band), an English pop band * ''The Schem ...
: 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 The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
provide
System.Numerics.Complex
since version 4.0. * The
smart BASIC Smart or SMART may refer to: Arts and entertainment * ''Smart'' (Hey! Say! JUMP album), 2014 * Smart (Hotels.com), former mascot of Hotels.com * ''Smart'' (Sleeper album), 1995 debut album by Sleeper * ''SMart'', a children's television ser ...
for
iOS iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
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 *
Julia Julia is usually a feminine given name. It is a Latinate feminine form of the name Julio and Julius. (For further details on etymology, see the Wiktionary entry "Julius".) The given name ''Julia'' had been in use throughout Late Antiquity (e.g ...
includes predefined types for both complex and rational numbers since at least version 0.3 * R provides a complex basic data type


References

{{DEFAULTSORT:Complex Data Type Data types