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


S>D Search:

In Programming and Stack Management Words in 32-bit library

Word Name: S>D
Type: Standard word
Data Stack Signature: s:x -- d:x
Return Stack Signature: --
Availability: V1.2
Description:

Converts a signed single value on the stack to a signed double value, by adding a 0 in the high order cell (for positive values) or a -1 for negative values.

Example:

21499 S>D .S (displays 21499 0)
-21499 S>D .S (displays -24199 -1)

This can be confirmed with D. as follows:

24199 S>D D. (displays 24199)
-24199 S>D D. (displays -24199)

Comment:

Note: Unsigned single values can be converted to a double simply by pushing a 0 on top of the value. For example, to convert the number 41999 to an unsigned-double:

41999 0 D. (displays 41999)

For clarity, this could be added as a colon definition:

: US>UD ( us – ud) 0 ;

Here “US>UD” means “unsigned-single to unsigned-double”. The stack signature shows an unsigned-single value on the top of the stack before conversion, and an unsigned-double value after the conversion.

See Also: None listed

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