summaryrefslogtreecommitdiff
path: root/docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm
diff options
context:
space:
mode:
Diffstat (limited to 'docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm')
-rw-r--r--docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm97
1 files changed, 97 insertions, 0 deletions
diff --git a/docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm b/docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm
new file mode 100644
index 0000000..9454d4e
--- /dev/null
+++ b/docsrc/xlisp/xlisp-doc/examples/common-lisp/mod.htm
@@ -0,0 +1,97 @@
+<html><head>
+
+<title>cl:mod</title>
+
+<style type="text/css">
+.example {
+ color: #000000;
+ background-color: #F5F5F5;
+ padding: 8px;
+ border: #808080;
+ border-style: solid;
+ border-width: 1px;
+ width:auto;
+}
+.button {
+ color: #000000;
+ background-color: #F5F5F5;
+ padding-top: 1px;
+ padding-bottom: 1px;
+ padding-left: 4px;
+ padding-right: 8px;
+ border: #808080;
+ border-style: solid;
+ border-width: 1px;
+ white-space: pre;
+}
+.box {
+ color: #000000;
+ padding-top: 4px;
+ padding-bottom: 4px;
+ padding-left: 16px;
+ padding-right: 16px;
+ border: #808080;
+ border-style: solid;
+ border-width: 1px;
+}
+</style>
+
+</head>
+
+<body>
+
+<a href="../../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
+<a href="../../manual/contents.htm">Contents</a> |
+<a href="../../tutorials/tutorials.htm">Tutorials</a> |
+<a href="../examples.htm">Examples</a> |
+<a href="../../reference/reference-index.htm">Reference</a>
+
+<hr>
+
+<h1>cl:mod</h1>
+
+<hr>
+
+<p><div class="box">
+
+<dl>
+<dt>(cl:<b>mod</b> <i>number divisor</i>)</dt>
+<dd><i>number</i> - an integer or floating-point number<br>
+<i>divisor</i> - an integer or floating-point number<br>
+returns - the remainder of a <a href="#cl-floor">cl:floor</a> operation</dd>
+</dl>
+
+</div></p>
+
+<pre class="example">
+(defun <font color="#0000CC">cl:mod</font> (number divisor)
+ (if (= (abs number) (abs divisor))
+ (if (and (integerp number) (integerp divisor)) 0 0.0)
+ (let* ((i-quotient (/ (truncate number) (truncate divisor)))
+ (f-quotient (/ (float number) divisor))
+ (quotient (if (or (= i-quotient f-quotient) <font color="#008844">; integer result</font>
+ (not (minusp f-quotient)))
+ (truncate f-quotient)
+ (1- (truncate f-quotient)))))
+ (- number (* quotient divisor)))))
+</pre>
+
+<p>The <nobr>cl:<b>mod</b></nobr> function performs the
+<a href="floor.htm">cl:floor</a> operation on its arguments and returns the
+remainder of the <a href="floor.htm">cl:floor</a> operation. <nobr>The
+result</nobr> is either zero or an integer or <nobr>floating-point</nobr>
+number with the same sign as the 'divisor' argument. <nobr>If both</nobr>
+arguments are integer numbers, the <nobr>cl:<b>mod</b></nobr> function is
+equal to the mathematical modulus function.</p>
+
+<p><nobr>&nbsp;&nbsp;<a href="#top">Back to top</a></nobr></p>
+
+<hr>
+
+<a href="../../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
+<a href="../../manual/contents.htm">Contents</a> |
+<a href="../../tutorials/tutorials.htm">Tutorials</a> |
+<a href="../examples.htm">Examples</a> |
+<a href="../../reference/reference-index.htm">Reference</a>
+
+</body></html>