[code]
[FONT=Courier New][COLOR=blue]public[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR] BitMask([COLOR=blue]int[/COLOR] MaskVal, [COLOR=blue]params[/COLOR] [COLOR=blue]int[/COLOR][] bitcheck)
[FONT=Courier New] {
[FONT=Courier New] [COLOR=#2b91af]Hashtable[/COLOR] ReturnThis = [COLOR=blue]new[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR]();
[FONT=Courier New] [COLOR=#2b91af]Hashtable[/COLOR] Arr = [COLOR=blue]new[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR]();
[FONT=Courier New] [COLOR=blue]int[/COLOR] loadbits = 8;
[FONT=Courier New] [COLOR=blue]try[/COLOR] { loadbits = bitcheck[0]; } [COLOR=blue]catch[/COLOR] ([COLOR=#2b91af]Exception[/COLOR]) { }
[FONT=Courier New]
[FONT=Courier New] [COLOR=green]/*
[COLOR=green][FONT=Courier New] * PHP SOURCE
[COLOR=green][FONT=Courier New] *
[COLOR=green][FONT=Courier New] * function bitmask ($bit = '', $loadbits = 8)
[COLOR=green][FONT=Courier New]* {
[COLOR=green][FONT=Courier New] * for ($i = 0 ; $i < $loadbits ; ++$i) {$arr[] = pow(2,$i); } // Automatisera bitvärden
[COLOR=green][FONT=Courier New] * for ($i = 0 ; $i < count($arr) ; ++$i) {$mask[$i] = ($bit & $arr[$i]) ? '1' : '0';} // Sätt 1 till de bitvärden som är påslagna
[COLOR=green][FONT=Courier New] * return $mask;
[COLOR=green][FONT=Courier New] * }
[COLOR=green][FONT=Courier New] */
[COLOR=green][FONT=Courier New]
[FONT=Courier New] [COLOR=blue]for[/COLOR] ([COLOR=blue]int[/COLOR] i = 0 ; i < loadbits ; ++i) {Arr.Add(i.ToString(), [COLOR=#2b91af]Math[/COLOR].Pow(2, i).ToString());} [COLOR=green]// Automatisera bitvärden
[COLOR=blue][FONT=Courier New]for[/FONT][/COLOR][FONT=Courier New] ([COLOR=blue]int[/COLOR] i = 0; i < Arr.Count; ++i) {ReturnThis.Add(i.ToString(), [COLOR=#2b91af]Convert[/COLOR].ToInt32([COLOR=#2b91af]Convert[/COLOR].ToBoolean(MaskVal & [COLOR=#2b91af]Convert[/COLOR].ToInt32(Arr[i.ToString()].ToString()))).ToString());}
[COLOR=blue][FONT=Courier New]return[/FONT][/COLOR][FONT=Courier New] ReturnThis;
[FONT=Courier New] }
[/code][FONT=Courier New]
