"Double" numbers in Tali use two 16-bit cells on the stack to make up a 32-bit number. This allows numbers from around -2.1 billion to +2.1 billion. You can deal with the halves as separate 16-bit values (most significant half is on top of stack) or use words like D. to print them and D+ to add them. To enter a double number, put a period after the last digit, eg: 1234567890.
Tali doesn't have the full double word set, but it has enough that all the "missing" words can be created if you need them. Here are some that I made while playing with FAT32 - some are ANS 2012 standard and some are just words I needed. In the stack comments, d = double, ud = unsigned double, n is a normal (signed 16-bit) number, u is an unsigned (16-bit) value, and f is a flag (true/false).
Code: Select all
\ Tali2 needs some extra double words.
: d= ( d1 d2 -- f )
rot = -rot = and ;
: d0= ( d -- f ) 0= swap 0= and ;
: d0<> ( d -- f ) or ;
: d2* ( d -- f ) 2dup d+ ;
: d< ( d -- f ) rot 2dup = if ( use LSBs ) 2drop <
else ( use MSBs ) 2swap 2drop > then ;
: d0! ( addr -- ) ( store double 0 at address )
0. rot 2! ; allow-native
: d+! ( d1 addr -- ) ( Add d1 to double at addr )
dup >r 2@ d+ r> 2! ;
: d1+! ( addr -- ) ( Add 1 to double at addr )
1. rot d+! ;
There are also 2CONSTANT and 2VARIABLE for constants and variables, 2DUP and 2DROP etc to manipulate them on the stack, etc. Most words that start with 2 (except 2* and 2/) work with double values. It's a bit unfortunate that some of the words start with 2 and others start with D, but that's how it is. You'll sometimes see the words used even with non-double values on the stack because (for example) 2DROP drops two items off the stack - it doesn't care if that was both halves of a double or two unrelated values.
Words that start with M are usually for "mixed" calculations, where one side is double and the other is not, eg M* (single value times a single value with a double result) and I bet you can figure out what UM* does now.
https://forth-standard.org, if you haven't found it already, will be very handy for reference as it covers the ANS 2012 Forth standard and I use the search function at the top all the time. The gotcha is that you kinda need to know the name of the word you want to know more about.