mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
glossary: clarify return values for / and /mod
FossilOrigin-Name: f7adfbdd0140497acc879a3dc83c9d8123fa984d4191c4366983009c957720f2
This commit is contained in:
parent
0e84fa08a8
commit
fbf7981f82
6 changed files with 20 additions and 16 deletions
|
@ -28,11 +28,11 @@ Execute the quotation if the flag is `FALSE`.
|
|||
-if; D: fq- A: - F: -
|
||||
Execute the quotation if the flag is `FALSE`. If false, also exit the word.
|
||||
|
||||
/ D: mn-o A: - F: -
|
||||
Divide `m` by `n` and return the result.
|
||||
/ D: nm-q A: - F: -
|
||||
Divide `n` by `m` and return the integer part of the quotient.
|
||||
|
||||
/mod D: nm-op A: - F: -
|
||||
Divide `n` by `m` and return the result and remainder.
|
||||
/mod D: nm-rq A: - F: -
|
||||
Divide `n` by `m` and return the integer part of the quotient and remainder.
|
||||
|
||||
0; D: n-n || n- A: - F: -
|
||||
If `n` is zero, drop `n` and exit the current word. If non-zero, leave `n` alone and allow execution to continue.
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
-eq? D: nn-f A: - F: -
|
||||
-if D: fq- A: - F: -
|
||||
-if; D: fq- A: - F: -
|
||||
/ D: mn-o A: - F: -
|
||||
/mod D: nm-op A: - F: -
|
||||
/ D: nm-q A: - F: -
|
||||
/mod D: nm-rq A: - F: -
|
||||
0; D: n-n || n- A: - F: -
|
||||
; D: - A: - F: -
|
||||
?dup D: n-nn || n-n A: - F: -
|
||||
|
|
|
@ -101,19 +101,19 @@
|
|||
<p><b>Class:</b> class:word | <b>Namespace:</b> global | <b>Interface Layer:</b> all</p>
|
||||
<hr/>
|
||||
<h1>/</h1>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> mn-o<br>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> nm-q<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Divide `m` by `n` and return the result.</p>
|
||||
<p>Divide `n` by `m` and return the integer part of the quotient.</p>
|
||||
<p><b>Class:</b> class:word | <b>Namespace:</b> global | <b>Interface Layer:</b> all</p>
|
||||
<hr/>
|
||||
<h1>/mod</h1>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> nm-op<br>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> nm-rq<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Divide `n` by `m` and return the result and remainder.</p>
|
||||
<p>Divide `n` by `m` and return the integer part of the quotient and remainder.</p>
|
||||
<p><b>Class:</b> class:primitive | <b>Namespace:</b> global | <b>Interface Layer:</b> all</p>
|
||||
<hr/>
|
||||
<h1>0;</h1>
|
||||
|
|
|
@ -137,22 +137,22 @@ Class: class:word | Namespace: global | Interface Layer: all
|
|||
|
||||
/
|
||||
|
||||
Data: mn-o
|
||||
Data: nm-q
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Divide `m` by `n` and return the result.
|
||||
Divide `n` by `m` and return the integer part of the quotient.
|
||||
|
||||
Class: class:word | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
/mod
|
||||
|
||||
Data: nm-op
|
||||
Data: nm-rq
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Divide `n` by `m` and return the result and remainder.
|
||||
Divide `n` by `m` and return the integer part of the quotient and remainder.
|
||||
|
||||
Class: class:primitive | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
|
|
@ -457,6 +457,10 @@ void inst_mul() {
|
|||
|
||||
**DIVMOD** divides and returns the quotient and remainder.
|
||||
|
||||
If using a C99 or newer compiler, this should return a remainder
|
||||
with the same sign as the dividend. If using an older compiler,
|
||||
you may need to alter this to achieve the expected results.
|
||||
|
||||
~~~
|
||||
void inst_divmod() {
|
||||
CELL a, b;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
-eq? nn-f - - Compare two values for inequality. Returns `TRUE` if they are not equal or `FALSE` otherwise. class:primitive #1 #2 -eq?\n $a $b -eq? {n/a} global all
|
||||
-if fq- - - Execute the quotation if the flag is `FALSE`. class:word {n/a} {n/a} global all
|
||||
-if; fq- - - Execute the quotation if the flag is `FALSE`. If false, also exit the word. class:word {n/a} {n/a} global all
|
||||
/ mn-o - - Divide `m` by `n` and return the result. class:word {n/a} {n/a} global all
|
||||
/mod nm-op - - Divide `n` by `m` and return the result and remainder. class:primitive {n/a} {n/a} global all
|
||||
/ nm-q - - Divide `n` by `m` and return the integer part of the quotient. class:word {n/a} {n/a} global all
|
||||
/mod nm-rq - - Divide `n` by `m` and return the integer part of the quotient and remainder. class:primitive {n/a} {n/a} global all
|
||||
0; n-n || n- - - If `n` is zero, drop `n` and exit the current word. If non-zero, leave `n` alone and allow execution to continue. class:macro {n/a} {n/a} global all
|
||||
; - - - End the current definition. class:macro {n/a} {n/a} global all
|
||||
?dup n-nn || n-n - - Duplicate top value on stack if not zero. If zero, do nothing. class:word #1 ?dup\n #0 ?dup {n/a} global all
|
||||
|
|
|
Loading…
Reference in a new issue