From WikiChip
Difference between revisions of "mirc/identifiers/$bitoff"
(Created page with "{{mirc title|$bitoff Identifier}} '''$bitoff''' returns N with the Bth bit set to 0. == Synopsis == <pre>$bitoff(<N>,<B>) </pre> == Parameters == N = Base-10 Number in the ra...") |
(→Parameters) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{mirc title|$bitoff | + | {{mirc title|$bitoff identifier}}'''$bitoff''' returns N with the Bth bit set to 0. |
− | '''$bitoff''' returns N with the Bth bit set to 0. | ||
== Synopsis == | == Synopsis == | ||
− | <pre>$bitoff(<N>,<B>) | + | <pre>$bitoff(<N>,<B>)</pre> |
− | </pre> | + | |
== Parameters == | == Parameters == | ||
− | N | + | * '''N''' - the number, in base10/decimal |
− | B | + | * '''B''' - The Bth bit to turn off |
+ | |||
== Properties == | == Properties == | ||
− | |||
None | None | ||
== Example == | == Example == | ||
− | |||
<pre>//var %n 10 | echo -a $bitoff(%n,2) | <pre>//var %n 10 | echo -a $bitoff(%n,2) | ||
; returns 8 | ; returns 8 | ||
Line 26: | Line 24: | ||
<pre>//var %n 10 | echo -a $base(%n,10,2,32) | echo -a $str(-,24) $+ 87654321 | echo -a $base($bitoff(%n,2),10,2,32) $base(1000,2,10) | <pre>//var %n 10 | echo -a $base(%n,10,2,32) | echo -a $str(-,24) $+ 87654321 | echo -a $base($bitoff(%n,2),10,2,32) $base(1000,2,10) | ||
; returns: | ; returns: | ||
− | + | 00000000000000000000000000001010 | |
------------------------87654321 | ------------------------87654321 | ||
− | + | 00000000000000000000000000001000 8 | |
</pre> | </pre> | ||
Line 45: | Line 43: | ||
if (%n == $null) var %n 3 | if (%n == $null) var %n 3 | ||
</pre> | </pre> | ||
− | |||
== Compatibility == | == Compatibility == | ||
Line 59: | Line 56: | ||
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
+ | [[Category:mIRC identifiers|bitoff]] |
Latest revision as of 12:15, 30 October 2017
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$bitoff returns N with the Bth bit set to 0.
Synopsis[edit]
$bitoff(<N>,<B>)
Parameters[edit]
- N - the number, in base10/decimal
- B - The Bth bit to turn off
Properties[edit]
None
Example[edit]
//var %n 10 | echo -a $bitoff(%n,2) ; returns 8
Here's how the answer was calculated:
- Convert base-10 N to binary.
- Count 2 from the right
- That bit is set to 0
- Return the possibly altered number
//var %n 10 | echo -a $base(%n,10,2,32) | echo -a $str(-,24) $+ 87654321 | echo -a $base($bitoff(%n,2),10,2,32) $base(1000,2,10) ; returns: 00000000000000000000000000001010 ------------------------87654321 00000000000000000000000000001000 8
If N is 2^32 or greater, returns 2^32 -1
If N is less than -2^31+1, returns 2^(B-1) +1
Using $biton and $bitoff, you can store several variables as bits within a single variable, instead of creating a separate variable for each.
The /window switch -wN uses bit settings, with default 3 if N not used.
var %treebarsetting $true var %switchbarsetting $true var %n if (%switchbarsetting) var %n $biton(%n,1) if (%treebarsetting) var %n $biton(%n,2) if (%n == $null) var %n 3
Compatibility[edit]
Added: mIRC v5.61
Added on: 23 Sep 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also[edit]
mIRC identifier list