In view of the requirement in ISO that the number be represented
in 2-complements
In
----------------------
\ Arithmetic on big signed-magnitude numbers.
\ Forth Scientific Library Algorithm #47
\ Copyright 1996 by Leonard Francis Zettel, Jr.
\ Released to the Forth Scientific Library. -------------------------------------
I see the following code:
-------------------------------
CREATE MAX-N CHAR M C, CHAR A C, CHAR X C, CHAR - C, CHAR N C,
\ Yes, this is clumsy, but it avoids making it necessary to specify
\ the use of S" from the File word set.
MAX-N 5 ENVIRONMENT? [IF] [ELSE] 32767 [THEN]
CONSTANT biggest \ Largest representable signed number -------------------------------
This relies on ENVIRONMENT? and defines clumsy auxiliary definitions.
In view of the requirement in ISO that the number be represented
in 2-complements that can be replaced by
-------------------------------
0 INVERT 1 RSHIFT CONSTANT biggest
-------------------------------
The advantage is if you are on a non-dancing, non-singing 64 bit
system that you don't have to throttle 48 bits from your
precision. No need to S" or ENVIRONMENT fully available.
Groetjes Albert
Looks like you're right. But I still wonder if this is universally true, given the many possible combinations of pointer and integer sizes
between different CPUs, like eg LP64I32 LLP64 and what you have
(how about 16 or 8 bitters?)
AFAIU a Forth cell should match the pointer size, not the integer size.
Looks like you're right. But I still wonder if this is universally true, >given the many possible combinations of pointer and integer sizes
between different CPUs
like eg LP64I32 LLP64 and what you have
(how about 16 or 8 bitters?)
AFAIU a Forth cell should match the pointer size, not the integer size.
"minf...@arcor.de" <minf...@arcor.de> writes:
Looks like you're right. But I still wonder if this is universally true, >given the many possible combinations of pointer and integer sizesForth has no pointers and not separate integers. Forth has cells.
between different CPUs
like eg LP64I32 LLP64 and what you haveThese are terms from the C world: L for long, P for pointer, I for
int, LL for long long. They have nothing to do with "different CPUs"
and nothing to do with Forth.
(how about 16 or 8 bitters?)What about them? On machines with 16-bit addresses cells are 16 bits
wide.
AFAIU a Forth cell should match the pointer size, not the integer size.That makes no sense. A cell contains an address or a single-cell
integer, so obviously they are the same size in Forth.
"minf...@arcor.de" <minforth@arcor.de> writes:
Looks like you're right. But I still wonder if this is universally true, >>given the many possible combinations of pointer and integer sizes
between different CPUs
Forth has no pointers and not separate integers. Forth has cells.
like eg LP64I32 LLP64 and what you have
These are terms from the C world: L for long, P for pointer, I for
int, LL for long long. They have nothing to do with "different CPUs"
and nothing to do with Forth.
(how about 16 or 8 bitters?)
What about them? On machines with 16-bit addresses cells are 16 bits
wide.
AFAIU a Forth cell should match the pointer size, not the integer size.
That makes no sense. A cell contains an address or a single-cell
integer, so obviously they are the same size in Forth.
- anton
In
----------------------
\ Arithmetic on big signed-magnitude numbers.
\ Forth Scientific Library Algorithm #47
\ Copyright 1996 by Leonard Francis Zettel, Jr.
\ Released to the Forth Scientific Library. >-------------------------------------
I see the following code:
-------------------------------
CREATE MAX-N CHAR M C, CHAR A C, CHAR X C, CHAR - C, CHAR N C,
\ Yes, this is clumsy, but it avoids making it necessary to specify
\ the use of S" from the File word set.
MAX-N 5 ENVIRONMENT? [IF] [ELSE] 32767 [THEN]
CONSTANT biggest \ Largest representable signed number >-------------------------------
This relies on ENVIRONMENT? and defines clumsy auxiliary definitions.
In view of the requirement in ISO that the number be represented
in 2-complements that can be replaced by
-------------------------------
0 INVERT 1 RSHIFT CONSTANT biggest
-------------------------------
The advantage is if you are on a non-dancing, non-singing 64 bit
system that you don't have to throttle 48 bits from your
precision. No need to S" or ENVIRONMENT fully available.
Anton Ertl schrieb am Montag, 2. Januar 2023 um 08:14:41 UTC+1:<SNIP>
AFAIU a Forth cell should match the pointer size, not the integer size.That makes no sense. A cell contains an address or a single-cell
integer, so obviously they are the same size in Forth.
Yes, of course, it is C lingo.
Bt still, looking at some meanwhile archaic Intel
CPUs you had 16 bit registers but addresses calculated through an additional >segment register. In DOS times there were Forths with different segments for >different purposes like for code and for headers. IIRC FPC had even more.
The notion of a modern Forth cell does not really match the CPU there. So
0 INVERT 1 RSHIFT CONSTANT biggest
works different for numbers or addresses (if you shun the word pointers).
But of course Forth like C silently implies a certain machine abstraction, >carried to the max if there is an underlying VM, where you work on an explicit >and visual hardware abstraction layer.
Anton Ertl schrieb am Montag, 2. Januar 2023 um 08:14:41 UTC+1:
"minf...@arcor.de" <minf...@arcor.de> writes:
Looks like you're right. But I still wonder if this is universally true,Forth has no pointers and not separate integers. Forth has cells.
given the many possible combinations of pointer and integer sizes
between different CPUs
like eg LP64I32 LLP64 and what you haveThese are terms from the C world: L for long, P for pointer, I for
int, LL for long long. They have nothing to do with "different CPUs"
and nothing to do with Forth.
(how about 16 or 8 bitters?)What about them? On machines with 16-bit addresses cells are 16 bits
wide.
AFAIU a Forth cell should match the pointer size, not the integer size.That makes no sense. A cell contains an address or a single-cell
integer, so obviously they are the same size in Forth.
Yes, of course, it is C lingo. But still, looking at some meanwhile archaic Intel
CPUs you had 16 bit registers but addresses calculated through an additional >segment register. In DOS times there were Forths with different segments for >different purposes like for code and for headers. IIRC FPC had even more.
The notion of a modern Forth cell does not really match the CPU there. So
0 INVERT 1 RSHIFT CONSTANT biggest
works different for numbers or addresses (if you shun the word pointers).
In article <2023Jan2.080430@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
"minf...@arcor.de" <minforth@arcor.de> writes:
AFAIU a Forth cell should match the pointer size, not the integer size.
That makes no sense. A cell contains an address or a single-cell
integer, so obviously they are the same size in Forth.
I can imagine (implement) an i386 Forth with 64 bits cell size.
Addressing beyond 32 bits gives an error.
However this situation does not make an address a separate data type.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 18:07:51 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,091 |