Next: , Previous: , Up: Arithmetic   [Contents][Index]

#### 5.5.2 Double precision

For the rules used by the text interpreter for recognising double-precision integers, see Number Conversion.

A double precision number is represented by a cell pair, with the most significant cell at the TOS. It is trivial to convert an unsigned single to a double: simply push a `0` onto the TOS. Since numbers are represented by Gforth using 2’s complement arithmetic, converting a signed single to a (signed) double requires sign-extension across the most significant cell. This can be achieved using `s>d`. The moral of the story is that you cannot convert a number without knowing whether it represents an unsigned or a signed number.

These words are all defined for signed operands, but some of them also work for unsigned numbers: `d+`, `d-`.

````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”
```

Next: Mixed precision, Previous: Single precision, Up: Arithmetic   [Contents][Index]