Debian Codegraph @

docsrc/xlisp/xlisp-doc/examples/common-lisp/remainder-and-modulus.htm

raw
1 <html><head>
2
3 <title>Remainder and Modulus</title>
4
5 <style type="text/css">
6 .example {
7 color: #000000;
8 background-color: #F5F5F5;
9 padding: 8px;
10 border: #808080;
11 border-style: solid;
12 border-width: 1px;
13 width:auto;
14 }
15 .button {
16 color: #000000;
17 background-color: #F5F5F5;
18 padding-top: 1px;
19 padding-bottom: 1px;
20 padding-left: 4px;
21 padding-right: 8px;
22 border: #808080;
23 border-style: solid;
24 border-width: 1px;
25 white-space: pre;
26 }
27 .box {
28 color: #000000;
29 padding-top: 4px;
30 padding-bottom: 4px;
31 padding-left: 16px;
32 padding-right: 16px;
33 border: #808080;
34 border-style: solid;
35 border-width: 1px;
36 }
37 </style>
38
39 </head>
40
41 <body>
42
43 <a href="../../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
44 <a href="../../manual/contents.htm">Contents</a> |
45 <a href="../../tutorials/tutorials.htm">Tutorials</a> |
46 <a href="../examples.htm">Examples</a> |
47 <a href="../../reference/reference-index.htm">Reference</a>
48
49 <hr>
50
51 <h1>Remainder and Modulus</h1>
52
53 <hr>
54
55 <p>The <a href="mod.htm">cl:mod</a> and <a href="rem.htm">cl:rem</a>
56 function are generalizations of the modulus and remainder functions.</p>
57
58 <ul>
59
60 <li><p><nobr>The <a href="mod.htm">cl:mod</a></nobr> function performs the
61 <a href="floor.htm">cl:floor</a> operation on its arguments and returns the
62 remainder of the <a href="floor.htm">cl:floor</a> operation.</p></li>
63
64 <li><p><nobr>The <a href="rem.htm">cl:rem</a></nobr> function performs the
65 <a href="truncate.htm">cl:truncate</a> operation on its arguments and returns
66 the remainder of the <a href="truncate.htm">cl:truncate</a> operation.</p></li>
67
68 </ul>
69
70 <p><nobr>The <a href="mod.htm">cl:mod</a></nobr> and
71 <a href="rem.htm">cl:rem</a> functions are the modulus and remainder
72 functions when the 'number' and 'divisor' arguments both are integers.</p>
73
74 <pre class="example">
75 (mod 13 4) =&gt; 1 (rem 13 4) =&gt; 1
76 (mod -13 4) =&gt; 3 (rem -13 4) =&gt; -1
77 (mod 13 -4) =&gt; -3 (rem 13 -4) =&gt; 1
78 (mod -13 -4) =&gt; -1 (rem -13 -4) =&gt; -1
79 (mod 13.4 1) =&gt; 0.4 (rem 13.4 1) =&gt; 0.4
80 (mod -13.4 1) =&gt; 0.6 (rem -13.4 1) =&gt; -0.4
81 </pre>
82
83 <p><nobr>&nbsp;&nbsp;<a href="#top">Back to top</a></nobr></p>
84
85 <hr>
86
87 <a href="../../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
88 <a href="../../manual/contents.htm">Contents</a> |
89 <a href="../../tutorials/tutorials.htm">Tutorials</a> |
90 <a href="../examples.htm">Examples</a> |
91 <a href="../../reference/reference-index.htm">Reference</a>
92
93 </body></html>