22 lines
		
	
	
	
		
			525 B
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
	
		
			525 B
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
|  | function ConvertTo-Bit { | ||
|  |     param ( | ||
|  |         [Int]$int | ||
|  |     ) | ||
|  |     [array]$bits = @() | ||
|  |     $test = $true | ||
|  |     while ($test -eq $true) { | ||
|  |         if (($int/2).GetType() -match [double]) { | ||
|  |             $int = ($int-1)/2 | ||
|  |             [array]$bits += 1 | ||
|  |         } | ||
|  |         elseif (($int/2).GetType() -match [int]) { | ||
|  |             $int = $int/2 | ||
|  |             [array]$bits += 0 | ||
|  |         } | ||
|  |         if ($int -eq 0) { | ||
|  |             $test = $false | ||
|  |         } | ||
|  |     } | ||
|  |     $bits =  $bits[-1..-999] | ||
|  |     ([string]($bits)) -replace "\s" | ||
|  | } |