| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>Syntax of a Float (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="Syntax of a Float (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="Syntax of a Float (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="Constructing-Numbers-from-Tokens.html" rel="up" title="Constructing Numbers from Tokens"> |
| 15 |
<link href="Syntax-of-a-Complex.html" rel="next" title="Syntax of a Complex"> |
| 16 |
<link href="Syntax-of-a-Ratio.html" rel="prev" title="Syntax of a Ratio"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="Syntax-of-a-Float"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Next: <a href="Syntax-of-a-Complex.html" accesskey="n" rel="next">Syntax of a Complex</a>, Previous: <a href="Syntax-of-a-Ratio.html" accesskey="p" rel="prev">Syntax of a Ratio</a>, Up: <a href="Constructing-Numbers-from-Tokens.html" accesskey="u" rel="up">Constructing Numbers from Tokens</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="Syntax-of-a-Float-1"></span><h4 class="subsubsection">2.3.2.4 Syntax of a Float</h4> |
| 46 |
|
| 47 |
<p><i>Floats</i> can be written in either decimal fraction or computerized |
| 48 |
scientific notation: an optional sign, then a non-empty sequence of digits |
| 49 |
with an embedded decimal point, |
| 50 |
then an optional decimal exponent specification. |
| 51 |
If there is no exponent specifier, then |
| 52 |
the decimal point is required, and there must be digits |
| 53 |
after it. |
| 54 |
The exponent specifier consists of an <i>exponent marker</i>, |
| 55 |
an optional sign, and a non-empty sequence of digits. |
| 56 |
If no exponent specifier is present, or if the <i>exponent marker</i> <tt>e</tt> |
| 57 |
(or <tt>E</tt>) is used, then |
| 58 |
the format specified |
| 59 |
by <b>*read-default-float-format*</b> is used. |
| 60 |
See <i>Figure~2–9</i>. |
| 61 |
</p> |
| 62 |
<p>An implementation may provide one or more kinds of <i>float</i> |
| 63 |
that collectively make up the <i>type</i> <b>float</b>. |
| 64 |
The letters <tt>s</tt>, <tt>f</tt>, <tt>d</tt>, and <tt>l</tt> (or their |
| 65 |
respective uppercase equivalents) explicitly specify the |
| 66 |
use of the <i>types</i> <b>short-float</b>, <b>single-float</b>, |
| 67 |
<b>double-float</b>, and <b>long-float</b>, respectively. |
| 68 |
</p> |
| 69 |
<p>The internal format used for an external representation depends only |
| 70 |
on the <i>exponent marker</i>, and not on the number of decimal digits |
| 71 |
in the external representation. |
| 72 |
</p> |
| 73 |
<p>Figure 2–14 contains examples of notations for <i>floats</i>: |
| 74 |
</p> |
| 75 |
<div class="format"> |
| 76 |
<pre class="format"> <tt>0.0</tt> ;Floating-point zero in default format <!-- /@w --> |
| 77 |
<tt>0E0</tt> ;As input, this is also floating-point zero in default format. <!-- /@w --> |
| 78 |
;As output, this would appear as <tt>0.0</tt>. <!-- /@w --> |
| 79 |
<tt>0e0</tt> ;As input, this is also floating-point zero in default format. <!-- /@w --> |
| 80 |
;As output, this would appear as <tt>0.0</tt>. <!-- /@w --> |
| 81 |
<tt>-.0</tt> ;As input, this might be a zero or a minus zero, <!-- /@w --> |
| 82 |
; depending on whether the implementation supports <!-- /@w --> |
| 83 |
; a distinct minus zero. <!-- /@w --> |
| 84 |
;As output, <tt>0.0</tt> is zero and <tt>-0.0</tt> is minus zero. <!-- /@w --> |
| 85 |
<tt>0.</tt> ;On input, the integer zero—<i>not</i> a floating-point number! <!-- /@w --> |
| 86 |
;Whether this appears as <tt>0</tt> or <tt>0.</tt> on output depends <!-- /@w --> |
| 87 |
;on the <i>value</i> of <b>*print-radix*</b>. <!-- /@w --> |
| 88 |
<tt>0.0s0</tt> ;A floating-point zero in short format <!-- /@w --> |
| 89 |
<tt>0s0</tt> ;As input, this is a floating-point zero in short format. <!-- /@w --> |
| 90 |
;As output, such a zero would appear as <tt>0.0s0</tt> <!-- /@w --> |
| 91 |
; (or as <tt>0.0</tt> if <b>short-float</b> was the default format). <!-- /@w --> |
| 92 |
<tt>6.02E+23</tt> ;Avogadro’s number, in default format <!-- /@w --> |
| 93 |
<tt>602E+21</tt> ;Also Avogadro’s number, in default format <!-- /@w --> |
| 94 |
|
| 95 |
Figure 2–14: Examples of Floating-point numbers <!-- /@w --> |
| 96 |
|
| 97 |
</pre></div> |
| 98 |
|
| 99 |
<p>For information on how <i>floats</i> are printed, |
| 100 |
see <a href="Printing-Floats.html">Printing Floats</a>. |
| 101 |
</p> |
| 102 |
<hr> |
| 103 |
<div class="header"> |
| 104 |
<p> |
| 105 |
Next: <a href="Syntax-of-a-Complex.html" accesskey="n" rel="next">Syntax of a Complex</a>, Previous: <a href="Syntax-of-a-Ratio.html" accesskey="p" rel="prev">Syntax of a Ratio</a>, Up: <a href="Constructing-Numbers-from-Tokens.html" accesskey="u" rel="up">Constructing Numbers from Tokens</a> </p> |
| 106 |
</div> |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
</body> |
| 111 |
</html> |