User Tools

A PCRE internal error occured. This might be caused by a faulty plugin

====== Function COMPLEX ====== ====Syntax==== * **complex //realpart ''&optional'' imagpart// → //complex// ====Arguments and Values==== * //realpart// - a //[[CL:Glossary:real]]//. * //imagpart// - a //[[CL:Glossary:real]]//. * //complex// - a //[[CL:Glossary:rational]]// or a //[[CL:Glossary:complex]]//. ====Description==== **complex** returns a //[[CL:Glossary:number]]// whose real part is //realpart// and whose imaginary part is //imagpart//. If //realpart// is a //[[CL:Glossary:rational]]// and //imagpart// is the //[[CL:Glossary:rational]]// number zero, the result of **complex** is //realpart//, a //[[CL:Glossary:rational]]//. Otherwise, the result is a //[[CL:Glossary:complex]]//. If either //realpart// or //imagpart// is a //[[CL:Glossary:float]]//, the non-//[[CL:Glossary:float]]// is converted to a //[[CL:Glossary:float]]// before the //[[CL:Glossary:complex]]// is created. If //imagpart// is not supplied, the imaginary part is a zero of the same //[[CL:Glossary:type]]// as //realpart//; i.e. ''([[CL:Functions:coerce]] 0 ([[CL:Functions:type-of]] //realpart//))'' is effectively used. Type upgrading implies a movement upwards in the type hierarchy lattice. In the case of //[[CL:Glossary:complex|complexes]]//, the //type-specifier// must be a subtype of ''(upgraded-complex-part-type //type-specifier//)''. If //type-specifier1// is a subtype of //type-specifier2//, then ''(upgraded-complex-element-type '//type-specifier1//)'' must also be a subtype of ''(upgraded-complex-element-type '//type-specifier2//)''. Two disjoint types can be upgraded into the same thing. ''#| TODO: fix this sentence, it doesn't make sense here. |#'' ====Examples==== <blockquote> (complex 0) <r>0 </r> (complex 0.0) <r>#C(0.0 0.0) </r> (complex 1 1/2) <r>#C(1 1/2)</r> (complex 1 .99) <r>#C(1.0 0.99) </r> (complex 3/2 0.0) <r>#C(1.5 0.0) </r> </blockquote> ====Side Effects==== None. ====Affected By==== None. ====Exceptional Situations==== None. ====See Also==== * **[[CL:Functions:realpart|Function REALPART]]** * **[[CL:Functions:imagpart|Function IMAGPART]]** * {\secref\SharpsignC} ====Notes==== None. \issue{ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS:UNIFY-UPGRADING}