|
|
Line 1: |
Line 1: |
| {{mirc title|$base Identifier}}The '''$base''' identifier converts numbers between different number bases, or zero-pads numbers to the desired length. | | {{mirc title|$base Identifier}}The '''$base''' identifier converts numbers between different number bases, or zero-pads numbers to the desired length. |
| + | |
| | | |
| == Synopsis == | | == Synopsis == |
Line 11: |
Line 12: |
| <span style="display: inline-block; width: 100px;">'''Precision'''</span>The output's maximum number of fraction digits, limited by mIRC's base-10 precision of 6.<br /> | | <span style="display: inline-block; width: 100px;">'''Precision'''</span>The output's maximum number of fraction digits, limited by mIRC's base-10 precision of 6.<br /> |
| | | |
− | '''Note''': InBase & Outbase can be any integer from 2-36, with Base 16-36 extending hexadecimal to use as many letters as needed from the G-Z range. Letters A-Z used by number bases 11 through 36 are case-insensitive. | + | '''Note:''' InBase & Outbase can be any integer from 2-36, with Base 17-36 extending hexadecimal to use as many letters as needed from the G-Z range. Letters A-Z used by number bases 11 through 36 are case-insensitive. |
| | | |
| == Properties == | | == Properties == |
− |
| |
| None | | None |
| | | |
| == Example == | | == Example == |
− |
| |
| <source lang="mIRC"> | | <source lang="mIRC"> |
| //var %n $color(8) | echo -a %n $base(%n,10,16,6) | | //var %n $color(8) | echo -a %n $base(%n,10,16,6) |
Line 55: |
Line 54: |
| == Compatibility == | | == Compatibility == |
| {{mIRC compatibility|5.7}} | | {{mIRC compatibility|5.7}} |
| + | |
| + | == See also == |
| + | * [[List of identifiers - mIRC]] |
| + | {{mIRC identifier list}} |
| + | [[Category:mIRC identifiers|base]] |
Revision as of 07:14, 21 September 2017
The $base identifier converts numbers between different number bases, or zero-pads numbers to the desired length.
Synopsis
$base(<N>,<InBase>,<OutBase>[,Zero-pad][,Precision])
Parameters
NThe Number being converted.
InBaseThe Number Base in which N is being expressed.
OutBaseThe Number Base to which N is being converted. Can be same as InBase.
ZeroPadThe output's minimum number of non-fraction digits by adding 0's if needed. Accepts up to 100.
PrecisionThe output's maximum number of fraction digits, limited by mIRC's base-10 precision of 6.
Note: InBase & Outbase can be any integer from 2-36, with Base 17-36 extending hexadecimal to use as many letters as needed from the G-Z range. Letters A-Z used by number bases 11 through 36 are case-insensitive.
Properties
None
Example
//var %n $color(8) | echo -a %n $base(%n,10,16,6)
//var %n $pi | echo -a %n $base(%n,10,16,0,12) $base($calc(%n * 16^6),10,16,6,12)
//var %n $crc(abc,0) | echo -a %n $base(%n,16,36,7)
//var %n $str(F,9) | echo -a converts 9-digit hex number %n to 7-digit base-36 $base(%n,16,36,7)
; returns: converts 9-digit hex number FFFFFFFFF to 7-digit base-36 VKHSVLR
You should not attempt to input numbers greater than decimal 2^53. For N=1+2^n, this shows that even though $base fails to convert back to the original number starting with N=55, $calc failed to create an odd-numbered number at N=53.
//var %i 1 | while (%i isnum 1-64) { var %n $calc(1+2^%i ) | echo -a %i %n $base(%n,10,16) $base($base(%n,10,16),16,10) | inc %i }
$base allows invalid letters to be used in the input, assigning them values as they have in Base 36.
//echo -a $base(mIRC,10,10) is same as $calc(22*1000 + 18*100 + 27*10+ 12*1)
The exception to the above is recognizing the 0x prefix for hexadecimal notation. Converting from base-16 to base1- results in 255 for both 0xFF and FF.
Compatibility
Added: mIRC v5.7
Added on: 02 Feb 2000
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also
v · d · e mIRC identifier list
$
$$, $, $0, $1-, $!, $&, $*, $+, $++, $?
A
$abook, $abs, $acos, $active, $activecid, $activewid, $adate, $address, $addtok, $addtokcs, $agent, $agentname, $agentstat, $agentver, $alias, $and, $anick, $ansi2mirc, $aop, $appactive, $appstate, $asc, $asctime, $asin, $atan, $atan2, $auto, $avoice, $away, $awaymsg, $awaytime
|
B
$banlist, $banmask, $base, $beta, $bfind, $bindip, $bitoff, $biton, $bits, $bnick, $bvar, $bytes
C
$calc, $caller, $cancel, $cb, $cd, $ceil, $chan, $chanmodes, $channel, $chantypes, $chat, $chr, $cid, $clevel, $click, $cmdbox, $cmdline, $cnick, $color, $colour, $com, $comcall, $comchan, $comchar, $comerr, $compact, $compress, $comval, $cos, $cosh, $count, $countcs, $cr, $crc, $creq, $crlf, $ctime, $ctimer, $ctrlenter
|
D
$date, $day, $daylight, $dbuh, $dbuw, $dccignore, $dccport, $dde, $ddename, $debug, $decode, $decompress, $deltok, $devent, $dialog, $did, $didreg, $didtok, $didwm, $dir, $disk, $dlevel, $dll, $dllcall, $dname, $dns, $donotdisturb, $dqwindow, $duration
E
$ebeeps, $editbox, $email, $emailaddr, $encode, $envvar, $error, $eval, $evalnext, $event, $eventid, $eventparms, $exists, $exiting
|
F
$false, $feof, $ferr, $fgetc, $file, $filename, $filtered, $find, $finddir, $finddirn, $findfile, $findfilen, $findtok, $findtokcs, $fline, $flinen, $floor, $font, $fopen, $fread, $fromeditbox, $fserv, $fserve, $fulladdress, $fulldate, $fullname, $fullscreen
|
G
$get, $getdir, $getdot, $gettok, $gmt, $group
H
$halted, $hash, $height, $hfile, $hfind, $hget, $highlight, $hmac $hmatch, $hnick, $host, $hotline, $hotlinepos, $hotlink, $hotp, $hregex, $hypot
|
I
$iaddress, $ial, $ialchan, $ibl, $idle, $iel, $ifmatch, $ifmatch2, $ignore, $iif, $iil, $inellipse, $ini, $initopic, $inmidi, $inmode, $inmp3, $inpaste, $inpoly, $input, $inrect, $inroundrect, $insong, $insongpause, $instok, $int, $intersect, $inwave, $inwho, $ip, $iptype, $iql, $isadmin, $isalias, $isbit, $isdde, $isdir, $isfile, $isid, $islower, $istok, $istokcs, $isupper, $isutf
|
K
$keychar, $keyrpt, $keyval, $knick
L
$lactive, $lactivecid, $lactivewid, $left, $leftwin, $leftwincid, $leftwinwid, $len, $level, $lf, $line, $lines, $link, $lock, $locked, $lof, $log, $log10, $logdir, $logstamp, $logstampfmt, $longfn, $longip, $lower, $ltimer
|
M
$maddress, $mask, $matchkey, $matchtok, $matchtokcs, $maxlenl, $maxlenm, $maxlens, $md5, $me, $menu, $menubar, $menucontext, $menutype, $mid, $mididir, $mircdir, $mircexe, $mircini, $mkfn, $mklogfn, $mknickfn, $mnick, $mode, $modefirst, $modelast, $modespl, $mouse, $mousecx, $mousecy, $mousedx, $mousedy, $mousekey, $mouselb, $mousex, $mousey, $mousewin, $mp3, $mp3dir, $msfile, $msgstamp, $msgtags
|
N
$N, $naddress, $network, $newnick, $nhnick, $nick, $nickmode, $no, $nofile, $nopath, $nopnick, $noqt, $not, $notags, $notify, $null, $numeric, $numtok, $nvnick
O
$ok, $online, $onlineserver, $onlinetotal $onpoly, $opnick, $or, $ord, $os
|
P
$parmN, $parms, $parseline, $parsetype, $parseutf, $passivedcc, $pi, $pic, $play, $pnick, $portable, $portfree, $pos, $poscs, $prefix, $prop, $protect, $puttok
Q
$qt, $query
R
$r, $raddress, $rand, $rands, $rawbytes, $rawmsg, $read, $readini, $readn, $regbr, $regerrstr, $regex, $regml, $regmlex, $regsub, $regsubex, $remote, $remove, $removecs, $remtok, $remtokcs, $replace, $replacecs, $replacex, $replacexcs, $reptok, $reptokcs, $result, $rgb, $right, $rnick, $round
|
S
$samepath, $scid, $scon, $script, $scriptdir, $scriptline, $sdir, $send, $server, $serverip, $servertarget, $sfile, $sha1, $sha256, $sha384, $sha512, $shortfn, $show, $signal, $sin, $sinh, $site, $sline, $snick, $snicks, $snotify, $sock, $sockbr, $sockerr, $sockname, $sorttok, $sorttokcs, $sound, $speak, $sqrt, $sreq, $ssl, $sslcertsha1, $sslcertsha256, $sslcertvalid, $ssldll, $ssllibdll, $sslready, $sslversion, $starting, $status, $str, $strip, $stripped, $style, $submenu, $switchbar, $sysdir
|
T
$tan, $tanh, $target, $tempfn, $ticks, $time, $timeout, $timer, $timestamp, $timestampfmt, $timezone, $tip, $tips, $titlebar, $token, $toolbar, $topic, $totp, $treebar, $true, $trust
U
$ulevel, $ulist, $unsafe, $upper, $uptime, $url, $usermode, $utfdecode, $utfencode
V
$v1, $v2, $var, $vc, $vcmd, $vcmdstat, $vcmdver, $version, $vnick, $vol
|
W
$wavedir, $wid, $width, $wildsite, $wildtok, $wildtokcs, $window, $wrap
|
X
$xor
Y
$yes
|
Z
$zip
=
=$nick
|