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


2, Search:

In Programming and Stack Management Words in 32-bit library

Word Name: 2,
Type: Standard word
Data Stack Signature: d:x –
Return Stack Signature: --
Availability: V1.2
Description:

Compiles a double-precision value on the stack directly to memory (at the address pointed to by HERE) as two consecutive cells.

Example:

CREATE FIBONACCI
0. 2, 1. 2, 1. 2, 2. 2, 3. 2, 5. 2,
8. 2, 13. 2, 21. 2, 34. 2, 55. 2, 89. 2,
144. 2, 233. 2, 377. 2, 610. 2, 987. 2, 1597. 2,
2584. 2, 4181. 2, 6765. 2, 10946. 2, 17711. 2, 28657. 2,
46368. 2, 75025. 2, 121393. 2, 196418. 2, 317811. 2,
: FIB? ( n – fibonacci) 1- 4 * FIBONACCI + 2@ D. ;
27 FIB?

(displays 121393)

Comment:

Note, the value is not compiled as a literal value, it is simply compiled to memory as two consecutive cells with no LIT instruction preceding them. 2, is used to compile lists or arrays of double precision numbers.

See Also: , (comma) 

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