Negative base numbers: Difference between revisions

added RPL
(Negative base numbers in FreeBASIC)
(added RPL)
(One intermediate revision by one other user not shown)
Line 2,188:
195 decoded in base -10 = 15
</pre>
=={{header|RPL}}==
{{trans||Python}}
« → base
« '''IF''' DUP NOT '''THEN''' →STR
'''ELSE'''
""
'''WHILE''' OVER '''REPEAT'''
base MOD LASTARG / FLOOR
'''IF''' OVER 0 < '''THEN'''
1 + SWAP
base -
'''ELSE''' SWAP '''END'''
ROT +
'''END''' SWAP DROP
» » '<span style="color:blue">→NEGB</span>' STO
« → nstr base
« 0
1 nstr SIZE '''FOR''' j
base *
nstr j DUP SUB STR→ +
'''NEXT'''
» » '<span style="color:blue">NEGB→</span>' STO
« { 10 -2 146 -3 15 -10 } → cases
« 1 cases SIZE '''FOR''' j
cases j GET cases j 1 + GET <span style="color:blue">→NEGB</span>
DUP cases j 1 + GET <span style="color:blue">NEGB→</span>
2 '''STEP'''
cases SIZE →LIST
» » '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
1: { "11110" 10 "21102" 146 "195" 15 }
</pre>
 
=={{header|Ruby}}==
{{trans|Julia}}
Line 2,559 ⟶ 2,595:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
1,150

edits