/ baseprefixes /

Number conversion prefixes in OTA & other systems

description:

The comp.lang.forth newsgroup has agreed on the following base prefixes:


Prefix Conversion base Example
% Binary %10101010 # Decimal #-13579 $ Hex $FE00


Some Forth systems use & for decimal (it's ok to have
both # and & for decimal) and a prefix for the octal base
is not needed.


description 2:

> ... OTA input number conversion may be directed to convert a
> particular number in a particular base, specified by a prefix character
> from Table 9. Following such a conversion, BASE remains unchanged from
> its prior value. If the number is to be negative, the minus sign must
> follow the prefix and precede the most significant digit.

Number conversion prefixes

Prefix Conversion base Example
% Binary %10101010 @ Octal @177 # Decimal #-13579 $ Hex $FE00




note 1:


Guido Draheim wrote:
>
> I see that it refers to OTA and a decimal-prefix
> of "#" - IIRC, this is what mpe-forth had as a
> decimal-prefix, and most probably swiftforth too.
>
> However, I remember another off-NG discussion
> with Anton Ertl and Tom Zimmer where we did
> talk about conversion-prefixes - it was not
> specifically about prefixes to be used, but
> now I use "&" for a decimal-prefix which is
> actually what I remember that was agreed upon.
>
> Therefore, while the commercial forthers
> did settle to "#", in the freeforth world
> it might look a bit different.


note 2:


SwiftForth uses a different set of number conversion prefixes:
>
> SwiftForth 2.2.2 09Mar2001
> HEX  ok
> %10 . 2  ok
> @10 . @10 ?
> #10 . A  ok
> $10 . 10  ok
> &10 . 8  ok


note 3:

Among these, only OTA is an official standard.



generated Tue Apr 28 11:05:53 2026runner