<# # #FS #S #> HOLD >NUMBER SIGN >pr
<# ( d ---)
Marks the start of converting a 32-bit number to a string of characters. P>
To convert a 16-bit number to a string, you will need to first convert this value to a 32-bit number:
55 s>d \ convert 55 16 bits in 32 bits format
# ( d1 --- d2)
Perform a division modulo the current numeric base and transform the rest of the
division into a string of characters. The character is dropped in the buffer set to
running <#
Example: converts a byte in hexadecimal format:
: hh ( c -- adr len) base @ >r hex <# # # #> r> base ! ; 3 hh type \ display 03 26 hh type \ display 1a
#FS ( r -- )
Specific ESP32forth
Converts a real number to a string. Used by f.
#S d1 --- d=0)
Converts the rest of d1 to a string in the character string initiated by
<#
. Example:
: EUROS ( d1 --- str len) <# # # \ convert € cents [char] , hold \ add char "," to str buffer #s #> \ convert rest after "," ; 15630. EUROS type \ display 156,30 ok
#> d1 --- adr len)
Converts a 32-bit number to a string. Leave on the stack
the address and length of the result chain of this conversion. To view this
string, use type
for example.
HOLD ( c ---)
Inserts the ASCII code of an ASCII character into the character string initiated by
<#
. Example:
: /nn ( d1 -- d2) [char] / hold \ add char "/" to str buffer # # \ add 2 chars to str buffer ; : dd/mm/yyyy ( d m y --- adr len) <# s>d # # # # \ convert year to sting "yyyy" /nn \ convert month to string "mm/" 2drop s>d /nn \ convert day to string "/dd/" #> ; 16 11 2019 dd/mm/yyyy type \ display 16/11/2019
>number ( ud c-addr1 u1 -- ud c-addr2 u2 )
Convert string to number
ud2 is the unsigned result of converting the characters within the string specified
by c-addr1 u1 into digits, using the number in BASE
, and adding each into ud1
after multiplying ud1 by the number in BASE
. Conversion continues left-to-right
until a character that is not convertible, including any "+" or "-", is encountered or
the string is entirely converted.
>pr ( c -- c )
Specific Flash Forth
Convert a character to a graphic ASCII value.
Non-graphic characters are converted to a dot.
SIGN ( n -- )
Inserts a - sign into the numeric output string if the integer on the top of the parameter stack is negative.