mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 09:58:06 +11:00
Clarify signed-ness
And fix broken negative display in ".".
This commit is contained in:
parent
b73e1a5f7a
commit
22f132094a
2
blk/003
2
blk/003
@ -9,4 +9,4 @@ Contents
|
||||
|
||||
4 DOES> 6 Compilation vs meta-comp.
|
||||
8 I/O 11 Chained comparisons
|
||||
14 Addressed devices
|
||||
14 Addressed devices 18 Signed-ness
|
||||
|
9
blk/018
Normal file
9
blk/018
Normal file
@ -0,0 +1,9 @@
|
||||
Signed-ness
|
||||
|
||||
For simplicity purposes, numbers are generally considered
|
||||
unsigned. For convenience, decimal parsing and formatting
|
||||
support the "-" prefix, but under the hood, it's all unsigned.
|
||||
|
||||
This leads to some oddities. For example, "-1 0 <" is false.
|
||||
To compare whether something is negative, use the "<0" word
|
||||
which is the equivalent to "0x7fff >".
|
2
blk/058
2
blk/058
@ -5,6 +5,6 @@ LIT -- Write a LIT entry. You're expected to write
|
||||
LIT< x -- Read following word and write to HERE as a
|
||||
string literal.
|
||||
LITS a -- Write word at addr a as a atring literal.
|
||||
S= a1 a2 -- f Compare strings a1 and a2, return true if equal
|
||||
S= a1 a2 -- f Returns whether string a1 == a2.
|
||||
SCPY a -- Copy string at addr a into HERE.
|
||||
SLEN a -- n Push length of str at a.
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
: >= < NOT ;
|
||||
: <= > NOT ;
|
||||
: <0 32767 > ;
|
||||
: >=0 <0 NOT ;
|
||||
|
||||
( n1 -- n1 true )
|
||||
: <>{ 1 ;
|
||||
|
@ -12,9 +12,7 @@
|
||||
|
||||
: . ( n -- )
|
||||
( handle negative )
|
||||
( that "0 1 -" thing is because we don't parse negative
|
||||
number correctly yet. )
|
||||
DUP 0 < IF '-' EMIT 0 1 - * THEN
|
||||
DUP <0 IF '-' EMIT -1 * THEN
|
||||
_
|
||||
BEGIN
|
||||
DUP '9' > IF DROP EXIT THEN ( stop indicator, we're done )
|
||||
|
@ -3,3 +3,4 @@
|
||||
0x42 <>{ 0x40 &> 0x44 &< <>} #
|
||||
0x44 <>{ 0x40 &> 0x44 &< <>} NOT #
|
||||
0x22 0x8065 < #
|
||||
-1 0 > #
|
||||
|
Loading…
Reference in New Issue
Block a user