Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
MsgBox % number2base(200, 16) ; 12
|
||||
MsgBox % parse(200, 16) ; 512
|
||||
|
||||
number2base(number, base)
|
||||
{
|
||||
While, base < digit := floor(number / base)
|
||||
{
|
||||
result := mod(number, base) . result
|
||||
number := digit
|
||||
}
|
||||
result := digit . result
|
||||
Return result
|
||||
}
|
||||
|
||||
parse(number, base)
|
||||
{
|
||||
result = 0
|
||||
pos := StrLen(number) - 1
|
||||
Loop, Parse, number
|
||||
{
|
||||
result := ((base ** pos) * A_LoopField) + result
|
||||
base -= 1
|
||||
}
|
||||
Return result
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
MsgBox % ToBase(29,3)
|
||||
MsgBox % ToBase(255,16)
|
||||
|
||||
MsgBox % FromBase("100",8)
|
||||
MsgBox % FromBase("ff",16)
|
||||
|
||||
ToBase(n,b) { ; n >= 0, 1 < b <= 36
|
||||
Return (n < b ? "" : ToBase(n//b,b)) . ((d:=mod(n,b)) < 10 ? d : Chr(d+87))
|
||||
}
|
||||
|
||||
FromBase(s,b) { ; convert base b number s=strings of 0..9,a..z, to AHK number
|
||||
Return (L:=StrLen(s))=0 ? "":(L>1 ? FromBase(SubStr(s,1,L-1),b)*b:0) + ((c:=Asc(SubStr(s,0)))>57 ? c-87:c-48)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue