Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #135095 > unrolled thread
| Started by | Matthias Koch <m.cook@gmx.net> |
|---|---|
| First post | 2026-05-25 14:58 +0200 |
| Last post | 2026-05-28 13:36 +0200 |
| Articles | 4 on this page of 24 — 6 participants |
Back to article view | Back to comp.lang.forth
Forth for a balanced ternary machine Matthias Koch <m.cook@gmx.net> - 2026-05-25 14:58 +0200
Re: Forth for a balanced ternary machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-25 18:10 +0000
Re: Forth for a balanced ternary machine dxf <dxforth@gmail.com> - 2026-05-26 15:53 +1000
Re: Forth for a balanced ternary machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-26 07:46 +0000
Re: Forth for a balanced ternary machine dxf <dxforth@gmail.com> - 2026-05-27 00:52 +1000
Teaching Scenarios [Re: Forth for a balanced ternary machine] Buzz McCool <buzz_mccool@yahoo.com> - 2026-05-26 08:52 -0700
Re: Teaching Scenarios [Re: Forth for a balanced ternary machine] dxf <dxforth@gmail.com> - 2026-05-28 21:03 +1000
Re: Teaching Scenarios [Re: Forth for a balanced ternary machine] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-30 20:16 +0000
Re: Teaching Scenarios [Re: Forth for a balanced ternary machine] minforth <minforth@gmx.net> - 2026-05-31 11:02 +0200
Re: Teaching Scenarios [Re: Forth for a balanced ternary machine] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-31 14:13 +0000
Division (was: Forth for a balanced ternary machine) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-30 18:23 +0000
Re: Division dxf <dxforth@gmail.com> - 2026-05-31 12:49 +1000
Re: Division anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-31 14:20 +0000
Re: Division dxf <dxforth@gmail.com> - 2026-06-01 12:47 +1000
arithmetic shift right (was: Division) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-31 14:43 +0000
Re: arithmetic shift right dxf <dxforth@gmail.com> - 2026-06-01 18:18 +1000
Re: Forth for a balanced ternary machine Hans Bezemer <the.beez.speaks@gmail.com> - 2026-06-01 23:23 +0200
Re: Forth for a balanced ternary machine dxf <dxforth@gmail.com> - 2026-06-03 13:30 +1000
Re: Forth for a balanced ternary machine Hans Bezemer <the.beez.speaks@gmail.com> - 2026-06-04 11:59 +0200
Re: Forth for a balanced ternary machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-06-04 12:15 +0000
Re: Forth for a balanced ternary machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-06-04 12:08 +0000
Re: Forth for a balanced ternary machine dxf <dxforth@gmail.com> - 2026-06-05 17:37 +1000
Re: Forth for a balanced ternary machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-06-05 09:22 +0000
Re: Forth for a balanced ternary machine Matthias Koch <m.cook@gmx.net> - 2026-05-28 13:36 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2026-06-04 12:08 +0000 |
| Message-ID | <2026Jun4.140819@mips.complang.tuwien.ac.at> |
| In reply to | #135124 |
dxf <dxforth@gmail.com> writes:
>On 2/06/2026 7:23 am, Hans Bezemer wrote:
>In eForth one finds:
>
> : 2* 2 * ;
> : 2/ 2 / ;
>
>which rather defeats the purpose of the functions which is speed.
But eForth's purpose is not speed.
>As to what is returned by a bit-shifting 2/ depends on the hardware.
>For 2's complement it's floored. For 1's complement it's symmetric.
>For signed-magnitude it's ...
For sign-magnitude an arithmetic interpretation is that, for positive
numbers, it's division by 2, while for negative numbers, it's the
average between the number and -2^(n-1) (where n is the number of bits
in a cell). It's not very useful for sign-magnitude, but given that
sign-magnitude and ones-complement have died out long ago and never
had Forth systems, who cares.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2025 proceedings: http://www.euroforth.org/ef25/papers/
[toc] | [prev] | [next] | [standalone]
| From | dxf <dxforth@gmail.com> |
|---|---|
| Date | 2026-06-05 17:37 +1000 |
| Message-ID | <6a227cb5@news.ausics.net> |
| In reply to | #135126 |
On 4/06/2026 10:08 pm, Anton Ertl wrote: > dxf <dxforth@gmail.com> writes: >> On 2/06/2026 7:23 am, Hans Bezemer wrote: >> In eForth one finds: >> >> : 2* 2 * ; >> : 2/ 2 / ; >> >> which rather defeats the purpose of the functions which is speed. > > But eForth's purpose is not speed. Wondering if there was a rationale for eForth, I found this from Bill Muench's old webpage: "I wrote eForth so that it would be easier for me to develop Forth systems for many processors. Processors included 56000, 6502, 68332, 68HC11, 8051, 8080, 80C166, 80C196, 80x86, RTX2000, RTX2001, RTX2010, SC32, StrongARM, TMS320, Z80, and I may have forgotten some. eForth allows me to make a complete Forth system with about 30 very simple machine code routines. With so few words to code, I could do the coding by hand, that is, without the need to write an assembler first. After this simple model is running, it is desirable to code much of the rest in assembly." That "30" figure perhaps explains why 1+ 1- 2+ 2- 2* 2/ were excluded from the kernel and provided as high-level definitions. The idea being users would eventually 'code' them. > >> As to what is returned by a bit-shifting 2/ depends on the hardware. >> For 2's complement it's floored. For 1's complement it's symmetric. >> For signed-magnitude it's ... > > For sign-magnitude an arithmetic interpretation is that, for positive > numbers, it's division by 2, while for negative numbers, it's the > average between the number and -2^(n-1) (where n is the number of bits > in a cell). It's not very useful for sign-magnitude, but given that > sign-magnitude and ones-complement have died out long ago and never > had Forth systems, who cares. Thanks. Not dead enough for Forth-94 which was the first standard to expressly mention and support them. For that reason I was curious what 2/ would do on these. As the effect does vary, I would expect '94 to have documented it. But then the same happened with other words.
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2026-06-05 09:22 +0000 |
| Message-ID | <2026Jun5.112240@mips.complang.tuwien.ac.at> |
| In reply to | #135130 |
dxf <dxforth@gmail.com> writes:
>On 4/06/2026 10:08 pm, Anton Ertl wrote:
[On 2/:]
>> It's not very useful for sign-magnitude, but given that
>> sign-magnitude and ones-complement have died out long ago and never
>> had Forth systems, who cares.
>
>Thanks. Not dead enough for Forth-94 which was the first standard to
>expressly mention and support them.
I think that's a reaction to the fact that Forth-83 limited itself to
16-bit cells and 8-bit chars. They wanted to lift those limitations,
and while they were at it, they apparently also wanted to eliminate
the limitation to 2s-complement representation of negative numbers.
Of these three, their cell size answer turned out to be right on spot,
while the char size answer turned out to be the wrong one (but it's in
the same spirit as the Windows NT (1993) and Java (1995) answers to
the same issue, so it's excusable that they did not see the right
answer in 1994. OTOH, the X/Open committee XoJIG, Dave Prosser and
Ken Thompson saw in 1992 that this answer was not the right one, and
designed UTF-8 in 1992.)
As for sign-magnitude and ones-complement, these are basically
remnants from the 1950s and 1960s, and I am not aware of a new
sign-magnitude or ones-complement architecture designed after the
1960s, except for followons to machines from the 1950s and 1960s.
These machines were in decline by the 1970s and the decline had
progressed pretty far by the time Forth-94 was developed.
Forth-94 gives lip service to these other representations, but does
not support them properly, especially not in a backwards-compatible
way. E.g., with ones complement code that uses 0= on the results of
comparisons (a common-usage way to negate the result) would not work
as intended.
And the treatment of 2/ is similar:
>For that reason I was curious what
>2/ would do on these. As the effect does vary, I would expect '94 to
>have documented it.
The effect of 2/ on the bits is documented. Given the different
results when applied to negative numbers, the use as arithmetic
operation on negative numbers is obviously not Forth-94 conforming.
All this is fixed by standardizing 2s-complent (already accepted into
the upcoming standard).
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2025 proceedings: http://www.euroforth.org/ef25/papers/
[toc] | [prev] | [next] | [standalone]
| From | Matthias Koch <m.cook@gmx.net> |
|---|---|
| Date | 2026-05-28 13:36 +0200 |
| Message-ID | <10v99b0$3dq7s$1@dont-email.me> |
| In reply to | #135097 |
Thank you for the insight into the symmetric vs. floored decision! I changed my documentation accordingly: In balanced ternary, a right shift is the same as symmetric division by powers of three, whereas in two-complement binary an arithmetic right shift is equivalent to floored division by powers of two.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.forth
csiph-web