Sujet : Re: Why dial-a-standard is not a thing in Forth
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 22. Apr 2025, 01:50:13
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <24bf7eaed4867bc968598dccedcceeb42764d9da@i2pn2.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
On 22/04/2025 12:19 am, sjack wrote:
dxf <dxforth@gmail.com> wrote:
>
Out of curiosity what was the conversion method?
>
-- CVD ( n_x -- n_decimal)
-- Convert to decimal
-- Split given 3 digit number into digits and
-- reassemble digits into a decimal number.
Base is used to get the digits but regardless of the base each digit
is treated as a decimal value, what the user had intended, and assembled
into a decimal number.
Thanks. So something like this ...
: CVD ( n1 -- n2 ) \ convert to decimal
3 0 do base @ /mod loop
3 0 do #10 * swap + loop ;
16 base ! 10 cvd decimal . 10 ok
2 base ! 10 cvd decimal . 10 ok
36 base ! -10 cvd decimal . -10 ok