A few days ago, I released an experiment on how Forth might adapt to
a balanced ternary architecture, with an instruction set emulator and
a native FPGA implementation included. In balanced ternary, all
numbers are signed with low-level arithmetic being quite elegant, and
there are new logic operators to explore. If you like to dive in: >https://codeberg.org/Mecrisp/mecrisp-ternary
Matthias Koch <m.cook@gmx.net> writes:
...
|In balanced ternary, a right shift is exactly the same as symmetric |division by powers of three, unlike binary in which right-shifting
|negative two-complement numbers to divide by powers of two gives
|rounding artifacts.
Floored division is not any more a rounding artifact than symmetric
division is. Whether to use floored or symmetric division depends on
the application. That's why we have FM/MOD and SM/REM in the
standard. The Forth-83 committee was so strongly in favour of floored
that they broke compatibility with Forth-79 because of that.
Gforth since 0.7 implements / and other division words where Forth-94
allows the system to choose as floored division words. This means
that in Gforth, "2 /" is equivalent to 2/ (which is defined as a shift
right by 1 bit):
-3 2 / . \ prints -2
-3 2/ . \ prints -2
On 26/05/2026 4:10 am, Anton Ertl wrote:
Gforth since 0.7 implements / and other division words where Forth-94
allows the system to choose as floored division words. This means
that in Gforth, "2 /" is equivalent to 2/ (which is defined as a shift
right by 1 bit):
-3 2 / . \ prints -2
-3 2/ . \ prints -2
Which is all very nice until beginners ask how that makes any sense ;-)
ANS at least tells you 2* 2/ are bit-shifters with historic, albeit misleading,
names.
dxf <dxforth@gmail.com> writes:
On 26/05/2026 4:10 am, Anton Ertl wrote:
Gforth since 0.7 implements / and other division words where Forth-94
allows the system to choose as floored division words. This means
that in Gforth, "2 /" is equivalent to 2/ (which is defined as a shift
right by 1 bit):
-3 2 / . \ prints -2
-3 2/ . \ prints -2
Which is all very nice until beginners ask how that makes any sense ;-)
They don't (I know because I have been teaching Forth beginners for
three decades). That's because negative dividends are rare, and
negative divisors are even rarer. But in those cases where negative dividends occur, floored division usually makes sense, and users
encountering it don't ask.
ANS at least tells you 2* 2/ are bit-shifters with historic, albeit misleading,
names.
The name of 2* is not misleading on architectures with 2s-complement arithmetic. I.e., every architecture designed in the last
half-century (the IBM S/360 is actually 62 years old), and everything
that any existing standard system (for any Forth standard) runs on.
...
... I have been teaching Forth beginners for three decades. ...
On 5/26/2026 12:46 AM, Anton Ertl wrote:
... I have been teaching Forth beginners for three decades. ...
Does your university offer a class on Forth?
https://dl.acm.org/doi/pdf/10.1145/165628.165632 https://www.cs.uaf.edu/~chappell/class/2023_spr/cs331/read/forth_quick.html
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,118 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 16:37:29 |
| Calls: | 14,340 |
| Calls today: | 3 |
| Files: | 186,356 |
| D/L today: |
2,561 files (804M bytes) |
| Messages: | 2,532,455 |