<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


#S Search:

In Double-Precision Numeric Display Words in 32-bit library

Word Name: #S
Type: Standard word
Data Stack Signature: ud:x – d:0
Return Stack Signature: --
Availability: V1.2
Description:

Converts all remaining digits until the value on the stack is 0 (i.e. there are no more digits to convert).

Example:

1234. <# #S #> TYPE (displays 1234)

Here, #S performs the same division technique as #, looping until the value on the stack is 0. It is possible to partially convert a number yourself manually, and then pass the remaining digits to #S to perform the rest of the conversion for you. This is particularly useful if you don't know the length of the number. For example:

123456. <# # # #S #> TYPE (displays 123456)

Here, the end result is the same: The example simply displays 123456, however, the first two digits (6 and 5) were converted manually, and the remaining digits (4321) were converted by #S and added to the PNO buffer automatically.

The following example formats a number by separating 100's from 1000's using a comma (see HOLD for more information on inserting characters into the PNO output):

123456. <# # # # ASCII , HOLD #S #> TYPE (displays 123,456)

Here, we manually processed the first three digits, then we manually inserted a comma character into the PNO stream using HOLD (see section 9.5). Finally, we let #S convert the rest of the number for us.

Comment:

None

See Also: <#  #  #> 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>