1
0
Fork 0
cl-sites/novaspec.org/cl/t_float.html
2025-02-05 18:52:26 +01:00

505 lines
No EOL
9.6 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>float | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="t_float.html"
><LINK REL="next" HREF="t_short-float.html" TYPE="text/html" TITLE="short-float, single-float, double-float, long-float"
><LINK REL="prev" HREF="t_real.html" TYPE="text/html" TITLE="real"
><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"
>&#8594; <A HREF="12_Numbers.html"
>12. Numbers</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="12_2_Numbers_Dictionary.html"
>12.2 Numbers Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="t_float.html"
>float</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="t_real.html" CLASS="prev"
>&#8592;</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="t_short-float.html" CLASS="next"
>&#8594;</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="float"
></SPAN
><B
>float</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>System</I
> <I
>Class</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Class Precedence List</B
></DT
><DD
><P CLASS="j"
><A HREF="t_float.html" CLASS="typeref"
><B
>float</B
></A
>, <A HREF="t_real.html" CLASS="typeref"
><B
>real</B
></A
>, <A HREF="t_number.html" CLASS="typeref"
><B
>number</B
></A
>, <A HREF="t_t.html" CLASS="typeref"
><B
>t</B
></A
></P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>A <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>float</EM
></A
> is a mathematical rational (but <I CLASS="i"
><I
>not</I
></I
> a Common Lisp <A HREF="26_1_Glossary.html#rational"
><EM CLASS="term"
>rational</EM
></A
>) of the form <I
>s</I
>&#8201;&#183;&#8201;<I
>f</I
>&#8201;&#183;&#8201;<I
>b</I
><SUP CLASS="sup"
><I
>e</I
>&#8201;<SPAN CLASS="cmsy"
>&#8722;</SPAN
>&#8201;<I
>p</I
></SUP
>, where <I
>s</I
> is +1 or &#8722;1, the <I CLASS="i"
><I
>sign</I
></I
>; <I
>b</I
> is an <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
> greater than&#160;1, the <I CLASS="i"
><I
>base</I
></I
> or <I CLASS="i"
><I
>radix</I
></I
> of the representation; <I
>p</I
> is a positive <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
>, the <I CLASS="i"
><I
>precision</I
></I
> (in base-<I
>b</I
> digits) of the <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>float</EM
></A
>; <I
>f</I
> is a positive <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
> between b<SUP CLASS="sup"
><SPAN CLASS="cmr"
>p-1</SPAN
></SUP
> and b<SUP CLASS="sup"
><SPAN CLASS="cmr"
>p</SPAN
></SUP
>-1 (inclusive), the significand; and <I
>e</I
> is an <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
>, the exponent. The value of <I
>p</I
> and the range of&#160;<I
>e</I
> depends on the implementation and on the type of <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>float</EM
></A
> within that implementation. In addition, there is a floating-point zero; depending on the implementation, there can also be a &#8220;minus zero&#8221;. If there is no minus zero, then 0<I
>.</I
>0 and&#160;&#8722;0<I
>.</I
>0 are both interpreted as simply a floating-point zero. <SPAN CLASS="cmtt"
>(=</SPAN
> <SPAN CLASS="cmtt"
>0.0</SPAN
> <SPAN CLASS="cmtt"
>-0.0)</SPAN
> is always true. If there is a minus zero, <SPAN CLASS="cmtt"
>(eql</SPAN
> <SPAN CLASS="cmtt"
>-0.0</SPAN
> <SPAN CLASS="cmtt"
>0.0)</SPAN
> is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>, otherwise it is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. </P
><P CLASS="j"
>The <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>types</EM
></A
> <A HREF="t_short-float.html" CLASS="typeref"
><B
>short-float</B
></A
>, <A HREF="t_short-float.html" CLASS="typeref"
><B
>single-float</B
></A
>, <A HREF="t_short-float.html" CLASS="typeref"
><B
>double-float</B
></A
>, and <A HREF="t_short-float.html" CLASS="typeref"
><B
>long-float</B
></A
> are <A HREF="26_1_Glossary.html#subtype"
><EM CLASS="term"
>subtypes</EM
></A
> of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_float.html" CLASS="typeref"
><B
>float</B
></A
>. Any two of them must be either <A HREF="26_1_Glossary.html#disjoint"
><EM CLASS="term"
>disjoint</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>types</EM
></A
> or the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
>; if the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
>, then any other <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>types</EM
></A
> between them in the above ordering must also be the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
>. For example, if the <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_short-float.html" CLASS="typeref"
><B
>single-float</B
></A
> and the <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_short-float.html" CLASS="typeref"
><B
>long-float</B
></A
> are the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
>, then the <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_short-float.html" CLASS="typeref"
><B
>double-float</B
></A
> must be the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> also.</P
></DD
><DT
><B
>Compound Type Specifier Kind</B
></DT
><DD
><P CLASS="j"
>Abbreviating.</P
></DD
><DT
><B
>Compound Type Specifier Syntax</B
></DT
><DD
><TABLE CELLSPACING="0" CELLPADDING="0" RULES="GROUPS" STYLE="margin: 1ex 0"
><TBODY
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";"
><SPAN CLASS="cmtt"
>(float</SPAN
> <SPAN CLASS="cmtt"
>[</SPAN
><SPAN CLASS="cmssi"
>lower-limit</SPAN
> <SPAN CLASS="cmr"
>[</SPAN
><SPAN CLASS="cmssi"
>upper-limit</SPAN
><SPAN CLASS="cmr"
>]</SPAN
><SPAN CLASS="cmtt"
>])</SPAN
></TD
></TR
></TBODY
></TABLE
></DD
><DT
><B
>Compound Type Specifier Arguments</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>lower-limit</VAR
>, <VAR CLASS="param"
>upper-limit</VAR
> &#8212; <A HREF="26_1_Glossary.html#interval_designator"
><EM CLASS="term"
>interval designators</EM
></A
> for <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_float.html" CLASS="typeref"
><B
>float</B
></A
>. The defaults for each of <VAR CLASS="param"
>lower-limit</VAR
> and <VAR CLASS="param"
>upper-limit</VAR
> is the <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> <SPAN CLASS="misc"
><B
>*</B
></SPAN
>.</P
></DD
><DT
><B
>Compound Type Specifier Description</B
></DT
><DD
><P CLASS="j"
>This denotes the <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>floats</EM
></A
> on the interval described by <VAR CLASS="param"
>lower-limit</VAR
> and <VAR CLASS="param"
>upper-limit</VAR
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
>Figure&#160;2&#8211;9, <A HREF="2_3_Interpretation_of_Tokens.html#sec_2_3_2" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>2.3.2</SPAN
> <SPAN CLASS="cmr"
>(Constructing</SPAN
> <SPAN CLASS="cmr"
>Numbers</SPAN
> <SPAN CLASS="cmr"
>from</SPAN
> <SPAN CLASS="cmr"
>Tokens)</SPAN
></A
>, <A HREF="22_1_The_Lisp_Printer.html#sec_22_1_3_1_3" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>22.1.3.1.3</SPAN
> <SPAN CLASS="cmr"
>(Printing</SPAN
> <SPAN CLASS="cmr"
>Floats)</SPAN
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
>Note that all mathematical integers are representable not only as Common Lisp <EM CLASS="term"
>reals</EM
>, but also as <A HREF="26_1_Glossary.html#complex_float"
><EM CLASS="term"
>complex floats</EM
></A
>. For example, possible representations of the mathematical number 1 include the <A HREF="26_1_Glossary.html#integer"
><EM CLASS="term"
>integer</EM
></A
> <CODE CLASS="f"
>1</CODE
>, the <A HREF="26_1_Glossary.html#float"
><EM CLASS="term"
>float</EM
></A
> <CODE CLASS="f"
>1.0</CODE
>, or the <A HREF="26_1_Glossary.html#complex"
><EM CLASS="term"
>complex</EM
></A
> <CODE CLASS="f"
>#C(1.0 0.0)</CODE
>.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="t_real.html" CLASS="prev"
>&#8592;</A
><A HREF="t_short-float.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>