1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<html><head><title>XLISP *integer-format*</title>
<link rel="stylesheet" type="text/css" href="reference.css">
</head>
<body>
<a href="../start.htm">Nyquist / XLISP 2.0</a> -
<a href="../manual/contents.htm">Contents</a> |
<a href="../tutorials/tutorials.htm">Tutorials</a> |
<a href="../examples/examples.htm">Examples</a> |
<a href="reference-index.htm">Reference</a>
<hr>
<h1>*integer-format*</h1>
<hr>
<p><table cellpadding="0" cellspacing="0" style="margin-left:10px"><tbody>
<tr valign="top">
<td><nobr>Type:</nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>system variable</nobr></td>
</tr>
<tr valign="top">
<td><nobr>Source:</nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>xlprin.c</nobr></td>
</tr>
</tbody></table></p>
<h2>Syntax</h2>
<dl>
<dt> *integer-format*</dt>
</dl>
<h2>Description</h2>
<p>*integer-format* is a system variable that allows a user to specify how
integer numbers are to be printed by XLISP. The value of *integer-format*
should be set to one of the string expressions "%ld",
"%lo" or "%lx" [the character after the percent
character is the lower-case 'L' character]. These format strings are similar
to C-language floating point specifications:</p>
<p><table cellpadding="0" cellspacing="0" style="margin-left:10px"><tbody>
<tr valign="top">
<td><nobr><code>"%ld"</code></nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>decimal</nobr></td>
</tr>
<tr valign="top">
<td><nobr><code>"%lu"</code></nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>unsigned decimal</nobr></td>
</tr>
<tr valign="top">
<td><nobr><code>"%lo"</code></nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>unsigned octal</nobr></td>
</tr>
<tr valign="top">
<td><nobr><code>"%lx"</code></nobr></td>
<td><nobr> - </nobr></td>
<td width="100%"><nobr>unsigned hexadecimal</nobr></td>
</tr>
</tbody></table></p>
<p>The default value for *integer-format* is the string "%ld".</p>
<h2>Examples</h2>
<pre class="example">
*integer-format* <font color="#008844">; returns "%ld"</font>
(setq *integer-format* "%ld") <font color="#008844">; signed decimal</font>
(print 1) <font color="#008844">; prints 1</font>
(print 1234) <font color="#008844">; prints 1234</font>
(print -1) <font color="#008844">; prints -1</font>
(print -1234) <font color="#008844">; prints -1234</font>
(setq *integer-format* "%lo") <font color="#008844">; octal notation</font>
(print 1) <font color="#008844">; prints 1</font>
(print 1234) <font color="#008844">; prints 2322</font>
(print -1) <font color="#008844">; prints 37777777777</font>
(print -1234) <font color="#008844">; prints 37777775456</font>
(setq *integer-format* "%lx") <font color="#008844">; hexadecimal notation</font>
(print 1) <font color="#008844">; prints 1</font>
(print -1) <font color="#008844">; prints ffffffff</font>
(print 1234) <font color="#008844">; prints 4d2</font>
(print -1234) <font color="#008844">; prints fffffb2e</font>
(setq *integer-format* "%u") <font color="#008844">; unsigned decimal</font>
(print 1) <font color="#008844">; prints 1</font>
(print 1234) <font color="#008844">; prints 1234</font>
(print -1) <font color="#008844">; prints 4294967295</font>
(print -1234) <font color="#008844">; prints 4294966062</font>
(setq *integer-format* "hi") <font color="#008844">; a bad notation</font>
(print 1) <font color="#008844">; prints hi</font>
(print 9999) <font color="#008844">; prints hi</font>
(setq *integer-format* "%ld") <font color="#008844">; reset to original "%ld"</font>
</pre>
<p><b>Note:</b> There can be other characters put in the string, but in
general, this will not produce particularly desirable behaviour. There is no
error checking performed on the format string.</p>
<p>See the
<a href="../manual/xlisp-man-011.htm#integer-format">*integer-format*</a>
system variable in the <nobr>XLISP 2.0</nobr> manual.</p>
<p><nobr> <a href="#top">Back to Top</nobr></a></p>
<hr>
<a href="../start.htm">Nyquist / XLISP 2.0</a> -
<a href="../manual/contents.htm">Contents</a> |
<a href="../tutorials/tutorials.htm">Tutorials</a> |
<a href="../examples/examples.htm">Examples</a> |
<a href="reference-index.htm">Reference</a>
</body></html>
|