Anonymous user
Non-decimal radices/Convert: Difference between revisions
m
→{{header|Caché ObjectScript}}
Line 415:
=={{header|Caché ObjectScript}}==
<lang cache>Class Utils.
{
ClassMethod
{
If pNum=0 Quit ""
Set str=..
Quit str_$Extract(pBaseStr, pNum#pBase+1)
}
ClassMethod
{
If pStr="" Quit 0
Set num=..
Set dec=$Find(pBaseStr, $Extract(pStr, *))-2
Quit num+(dec*(pBase**pPos))
}
ClassMethod
{
// some initialisation
Line 462:
Set pStr=pStr
} ElseIf pFrom=10 {
Set pStr=..
} ElseIf pTo=10 {
Set pStr=..
} Else {
Set pStr=..
}
// return value
If pLen=0 Quit pStr
If pTo'=10 Quit ..
Quit ..
}
ClassMethod
{
If $Length(
Quit $Translate($Justify(
}
}</lang>
{{out|Examples}}
<pre>
ABCD
Line 491 ⟶ 492:
26
USER>Write ##class(Utils.
1A
USER>Write ##class(Utils.
26
USER>Write ##class(Utils.
A9XUCDBHK6
USER>Write ##class(Utils.
6234900123456700</pre>
|