3 ( Write n spaces to stdout. )
11 ( This is the underlying recursive definition of U. )
13 BASE @ /MOD ( width rem quot )
14 ?DUP IF ( if quotient <> 0 then )
15 RECURSE ( print the quotient )
18 ( print the remainder )
20 [CHAR] 0 ( decimal digits 0..9 )
22 10 - ( hex and beyond digits A..Z )
29 ( This word returns the width (in characters) of an unsigned number in the current base )
30 : UWIDTH ( u -- width )
32 ?DUP IF ( if quotient <> 0 then )
33 RECURSE 1+ ( return 1+recursive call )
42 UWIDTH ( width u uwidth )
43 ROT ( u uwidth width )
44 SWAP - ( u width-uwidth )
45 ( At this point if the requested width is narrower, we'll have a negative number on the stack.
46 Otherwise the number on the stack is the number of spaces to print. But SPACES won't print
47 a negative number of spaces anyway, so it's now safe to call SPACES ... )
49 ( ... and then call the underlying implementation of U. )
57 1 ( save a flag to remember that it was negative | width n 1 )
67 DUP ( flag width u u )
68 UWIDTH ( flag width u uwidth )
69 ROT ( flag u uwidth width )
70 SWAP - ( flag u width-uwidth )
75 IF ( was it negative? print the - character )
85 [CHAR] < EMIT DEPTH U. [CHAR] > EMIT SPACE
98 ( ? fetches the integer at an address and prints it. )
101 ( c a b WITHIN returns true if a <= c and c < b )