329 lines
No EOL
6.6 KiB
HTML
329 lines
No EOL
6.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<HTML LANG="en-us"
|
|
><HEAD
|
|
><TITLE
|
|
>complex | Common Lisp Nova Spec</TITLE
|
|
><META CHARSET="US-ASCII"
|
|
><LINK REL="canonical" HREF="f_complex.html"
|
|
><LINK REL="next" HREF="f_complexp.html" TYPE="text/html" TITLE="complexp"
|
|
><LINK REL="prev" HREF="f_cis.html" TYPE="text/html" TITLE="cis"
|
|
><LINK REL="up" HREF="12_2_Numbers_Dictionary.html" TYPE="text/html" TITLE="12.2 Numbers Dictionary"
|
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
|
></SCRIPT
|
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
|
></SCRIPT
|
|
></HEAD
|
|
><BODY
|
|
><DIV
|
|
><DIV CLASS="topnav"
|
|
><DIV CLASS="breadcrumb"
|
|
><SPAN CLASS="breadcrumb-item"
|
|
><A HREF="index.html"
|
|
>Common Lisp Nova Spec</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="12_Numbers.html"
|
|
>12. Numbers</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="12_2_Numbers_Dictionary.html"
|
|
>12.2 Numbers Dictionary</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="f_complex.html"
|
|
>complex</A
|
|
></SPAN
|
|
></DIV
|
|
><DIV CLASS="apropos"
|
|
><DIV CLASS="apropos-io"
|
|
><A HREF="f_cis.html" CLASS="prev"
|
|
>←</A
|
|
><SPAN ID="apropos-label"
|
|
>Apropos </SPAN
|
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
|
><A HREF="f_complexp.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV ID="apropos-res"
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="matter"
|
|
><DIV CLASS="com"
|
|
><DIV CLASS="begincom"
|
|
><HR
|
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
|
><TR
|
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="complex"
|
|
></SPAN
|
|
><B
|
|
>complex</B
|
|
></TD
|
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
|
><I
|
|
>Function</I
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
></DIV
|
|
><UL CLASS="subtoc"
|
|
></UL
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Syntax</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><B
|
|
>complex</B
|
|
> <SPAN CLASS="cmssi"
|
|
>realpart</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>&optional</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>imagpart</SPAN
|
|
> <SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>complex</SPAN
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Arguments and Values</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>realpart</VAR
|
|
> — a <EM CLASS="term"
|
|
>real</EM
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>imagpart</VAR
|
|
> — a <EM CLASS="term"
|
|
>real</EM
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>complex</VAR
|
|
> — a <A HREF="26_1_Glossary.html#rational"
|
|
><EM CLASS="term"
|
|
>rational</EM
|
|
></A
|
|
> or a <A HREF="26_1_Glossary.html#complex"
|
|
><EM CLASS="term"
|
|
>complex</EM
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Description</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_complex.html" CLASS="funref"
|
|
><B
|
|
>complex</B
|
|
></A
|
|
> returns a <A HREF="26_1_Glossary.html#number"
|
|
><EM CLASS="term"
|
|
>number</EM
|
|
></A
|
|
> whose real part is <VAR CLASS="param"
|
|
>realpart</VAR
|
|
> and whose imaginary part is <VAR CLASS="param"
|
|
>imagpart</VAR
|
|
>. </P
|
|
><P CLASS="j"
|
|
>If <VAR CLASS="param"
|
|
>realpart</VAR
|
|
> is a <A HREF="26_1_Glossary.html#rational"
|
|
><EM CLASS="term"
|
|
>rational</EM
|
|
></A
|
|
> and <VAR CLASS="param"
|
|
>imagpart</VAR
|
|
> is the <A HREF="26_1_Glossary.html#rational"
|
|
><EM CLASS="term"
|
|
>rational</EM
|
|
></A
|
|
> number zero, the result of <A HREF="f_complex.html" CLASS="funref"
|
|
><B
|
|
>complex</B
|
|
></A
|
|
> is <VAR CLASS="param"
|
|
>realpart</VAR
|
|
>, a <A HREF="26_1_Glossary.html#rational"
|
|
><EM CLASS="term"
|
|
>rational</EM
|
|
></A
|
|
>. Otherwise, the result is a <A HREF="26_1_Glossary.html#complex"
|
|
><EM CLASS="term"
|
|
>complex</EM
|
|
></A
|
|
>. </P
|
|
><P CLASS="j"
|
|
>If either <VAR CLASS="param"
|
|
>realpart</VAR
|
|
> or <VAR CLASS="param"
|
|
>imagpart</VAR
|
|
> is a <A HREF="26_1_Glossary.html#float"
|
|
><EM CLASS="term"
|
|
>float</EM
|
|
></A
|
|
>, the non-<A HREF="26_1_Glossary.html#float"
|
|
><EM CLASS="term"
|
|
>float</EM
|
|
></A
|
|
> is converted to a <A HREF="26_1_Glossary.html#float"
|
|
><EM CLASS="term"
|
|
>float</EM
|
|
></A
|
|
> before the <A HREF="26_1_Glossary.html#complex"
|
|
><EM CLASS="term"
|
|
>complex</EM
|
|
></A
|
|
> is created. If <VAR CLASS="param"
|
|
>imagpart</VAR
|
|
> is not supplied, the imaginary part is a zero of the same <A HREF="26_1_Glossary.html#type"
|
|
><EM CLASS="term"
|
|
>type</EM
|
|
></A
|
|
> as <VAR CLASS="param"
|
|
>realpart</VAR
|
|
>; <I CLASS="i"
|
|
><I
|
|
>i.e.</I
|
|
></I
|
|
>, <SPAN CLASS="cmtt"
|
|
>(coerce</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>0</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>(type-of</SPAN
|
|
> <VAR CLASS="param"
|
|
>realpart</VAR
|
|
><SPAN CLASS="cmtt"
|
|
>))</SPAN
|
|
> is effectively used. </P
|
|
><P CLASS="j"
|
|
>Type upgrading implies a movement upwards in the type hierarchy lattice. In the case of <A HREF="26_1_Glossary.html#complex"
|
|
><EM CLASS="term"
|
|
>complexes</EM
|
|
></A
|
|
>, the <VAR CLASS="param"
|
|
>type-specifier</VAR
|
|
> must be a subtype of <SPAN CLASS="cmtt"
|
|
>(upgraded-complex-part-type</SPAN
|
|
> <VAR CLASS="param"
|
|
>type-specifier</VAR
|
|
><SPAN CLASS="cmtt"
|
|
>)</SPAN
|
|
>. If <VAR CLASS="param"
|
|
>type-specifier1</VAR
|
|
> is a subtype of <VAR CLASS="param"
|
|
>type-specifier2</VAR
|
|
>, then <SPAN CLASS="cmtt"
|
|
>(upgraded-complex-element-type</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>'</SPAN
|
|
><VAR CLASS="param"
|
|
>type-specifier1</VAR
|
|
><SPAN CLASS="cmtt"
|
|
>)</SPAN
|
|
> must also be a subtype of <SPAN CLASS="cmtt"
|
|
>(upgraded-complex-element-type</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>'</SPAN
|
|
><VAR CLASS="param"
|
|
>type-specifier2</VAR
|
|
><SPAN CLASS="cmtt"
|
|
>)</SPAN
|
|
>. Two disjoint types can be upgraded into the same thing.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Examples</B
|
|
></DT
|
|
><DD
|
|
><PRE CLASS="screen"
|
|
>(complex 0) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> 0
|
|
(complex 0.0) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> #C(0.0 0.0)
|
|
(complex 1 1/2) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> #C(1 1/2)
|
|
(complex 1 .99) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> #C(1.0 0.99)
|
|
(complex 3/2 0.0) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> #C(1.5 0.0)</PRE
|
|
></DD
|
|
><DT
|
|
><B
|
|
>See Also</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_realpart.html" CLASS="funref"
|
|
><B
|
|
>realpart</B
|
|
></A
|
|
>, <A HREF="f_realpart.html" CLASS="funref"
|
|
><B
|
|
>imagpart</B
|
|
></A
|
|
>, <A HREF="2_4_Standard_Macro_Characters.html#sec_2_4_8_11" CLASS="secref"
|
|
><SPAN CLASS="cmr"
|
|
>Section</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>2.4.8.11</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>(Sharpsign</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>C)</SPAN
|
|
></A
|
|
></P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="footer"
|
|
><DIV CLASS="btmnav"
|
|
><A HREF="f_cis.html" CLASS="prev"
|
|
>←</A
|
|
><A HREF="f_complexp.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV CLASS="trail"
|
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
|
></DIV
|
|
></DIV
|
|
><SCRIPT
|
|
>domReady();</SCRIPT
|
|
></BODY
|
|
></HTML
|
|
> |