emacs.d/clones/lisp/HyperSpec-7-0/HyperSpec/Body/02_cbb.htm
2023-01-18 20:30:47 +01:00

54 lines
5.9 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 2.3.2.2</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="02_cbab.htm">
<LINK REL=UP HREF="02_cb.htm">
<LINK REL=NEXT HREF="02_cbc.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="02_cbab.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="02_cb.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="02_cbc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
2.3.2.2 Syntax of a Float</H2> <P>
<A REL=DEFINITION HREF="26_glo_f.htm#float"><I>Floats</I></A> can be written in either decimal fraction or computerized scientific notation: an optional sign, then a non-empty sequence of digits with an embedded decimal point, then an optional decimal exponent specification. If there is no exponent specifier, then the decimal point is required, and there must be digits after it. The exponent specifier consists of an <A REL=DEFINITION HREF="26_glo_e.htm#exponent_marker"><I>exponent marker</I></A>, an optional sign, and a non-empty sequence of digits. If no exponent specifier is present, or if the <A REL=DEFINITION HREF="26_glo_e.htm#exponent_marker"><I>exponent marker</I></A> <TT>e</TT> (or <TT>E</TT>) is used, then the format specified by <A REL=DEFINITION HREF="v_rd_def.htm#STread-default-float-formatST"><B>*read-default-float-format*</B></A> is used. See <A REL=DEFINITION HREF="02_ca.htm#syntaxfornumerictokens">Figure 2-9</A>. <P>
An implementation may provide one or more kinds of <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A> that collectively make up the <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="t_float.htm#float"><B>float</B></A>. The letters <TT>s</TT>, <TT>f</TT>, <TT>d</TT>, and <TT>l</TT> (or their respective uppercase equivalents) explicitly specify the use of the <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A> <A REL=DEFINITION HREF="t_short_.htm#short-float"><B>short-float</B></A>, <A REL=DEFINITION HREF="t_short_.htm#single-float"><B>single-float</B></A>, <A REL=DEFINITION HREF="t_short_.htm#double-float"><B>double-float</B></A>, and <A REL=DEFINITION HREF="t_short_.htm#long-float"><B>long-float</B></A>, respectively. <P>
The internal format used for an external representation depends only on the <A REL=DEFINITION HREF="26_glo_e.htm#exponent_marker"><I>exponent marker</I></A>, and not on the number of decimal digits in the external representation. <P>
The next figure contains examples of notations for <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>floats</I></A>: <P>
<PRE>
0.0 ;Floating-point zero in default format
0E0 ;As input, this is also floating-point zero in default format.
;As output, this would appear as 0.0.
0e0 ;As input, this is also floating-point zero in default format.
;As output, this would appear as 0.0.
-.0 ;As input, this might be a zero or a minus zero,
; depending on whether the implementation supports
; a distinct minus zero.
;As output, 0.0 is zero and -0.0 is minus zero.
0. ;On input, the integer zero---not a floating-point number!
;Whether this appears as 0 or 0. on output depends
;on the <A REL=DEFINITION HREF="26_glo_v.htm#value">value</A> of <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-radixST">*print-radix*</A>.
0.0s0 ;A floating-point zero in short format
0s0 ;As input, this is a floating-point zero in short format.
;As output, such a zero would appear as 0.0s0
; (or as 0.0 if <A REL=DEFINITION HREF="t_short_.htm#short-float">short-float</A> was the default format).
6.02E+23 ;Avogadro's number, in default format
602E+21 ;Also Avogadro's number, in default format
</PRE>
<P><B>Figure 2-14. Examples of Floating-point numbers</B> <P>
For information on how <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>floats</I></A> are printed, see <A REL=CHILD HREF="22_acac.htm">Section 22.1.3.1.3 (Printing Floats)</A>. <P>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>