For the rules used by the text interpreter for recognising double-precision integers, see Literals.
A double precision number is represented by a cell pair, with the most
significant cell at the top-of-stack (TOS). It is trivial to convert
an unsigned single to a double: simply push a 0
onto the
TOS. Numbers are represented by Gforth using 2’s complement
arithmetic, so converting a signed single to a (signed) double
requires sign-extension across the most significant cell. This can be
achieved using s>d
. You cannot convert a number from
single-cell to double-cell without knowing whether it represents an
unsigned or a signed number. By contrast, in 2’s complement
arithmetic the conversion from double to single just drop
s the
most significant cell, and d>s
just documents the intent.
D+
and d-
are defined for signed operands, but also work
for unsigned numbers.
s>d
( n – d ) core “s-to-d”
d>s
( d – n ) double “d-to-s”
d+
( ud1 ud2 – ud ) double “d-plus”
d-
( d1 d2 – d ) double “d-minus”
dnegate
( d1 – d2 ) double “d-negate”
dabs
( d – ud ) double “d-abs”
dmin
( d1 d2 – d ) double “d-min”
dmax
( d1 d2 – d ) double “d-max”