bit

Switch on Enum (with Flags attribute) without declaring every possible combination?

谁都会走 提交于 2019-12-03 04:04:43
问题 how do i switch on an enum which have the flags attribute set (or more precisely is used for bit operations) ? I want to be able to hit all cases in a switch that matches the values declared. The problem is that if i have the following enum [Flags()]public enum CheckType { Form = 1, QueryString = 2, TempData = 4, } and I want to use a switch like this switch(theCheckType) { case CheckType.Form: DoSomething(/*Some type of collection is passed */); break; case CheckType.QueryString:

基本单位bit和Byte

帅比萌擦擦* 提交于 2019-12-03 03:47:54
bit: (位)二进制,一个数字0或者是一个数字1代表一位 Byte: (字节)计算机存储的最小单元 1 Byte = 8 bit 误区: 当宽带为100兆宽带的时候,下载速度却没有100兆,是因为: 宽带说的100兆指的是: 100Mbps,也就是100兆个位 下载速度的100兆指的是: 100MB/s,也就是下载速度为100兆字节每秒 因此,100兆宽带实际理论上 下载速度为:100 Mbps / 8 = 12.5MB/s 1 KB = 1024 Byte 1 MB = 1024 KB 1 GB = 1024 MB 1 TB = 1024 GB 移动硬盘所在的大小 1 PB = 1024 TB 1 EB = 1024 PB 服务器所在的大小 1 ZB = 1024 EB 来源: https://www.cnblogs.com/KeepCalmAndNeverSayNever/p/11775288.html

Why is number of bits always(?) a power of two?

╄→гoц情女王★ 提交于 2019-12-03 03:25:50
问题 We have 8-bit, 16-bit, 32-bit and 64-bit hardware architectures and operating systems. But not, say, 42-bit or 69-bit ones. Why? Is it something fundamental that makes 2^n bits a better choice, or is just about compatibility with existing systems? (It's obviously convenient that a 64-bit register can hold two 32-bit pointers, or that a 32-bit data unit can hold 4 bytes.) 回答1: That's mostly a matter of tradition. It is not even always true. For example, floating-point units in processors (even

Python: reading 12 bit packed binary image

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a 12 bit packed image from a GigE camera. It is a little-endian file and each 3 bytes hold 2 12-bit pixels. I am trying to read this image using python and I tried something like this: import bitstring import numpy with open('12bitpacked1.bin', 'rb') as f: data = f.read() ii=numpy.zeros(2*len(data)/3) ic = 0 for oo in range(0,len(data)/3): aa = bitstring.Bits(bytes=data[oo:oo+3], length=24) ii[ic],ii[ic+1] = aa.unpack('uint:12,uint:12') ic=ic+2 b = numpy.reshape(ii,(484,644)) In short: I read 3 bytes, convert them to bits and then

Python Create Access database using win32com

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create an Access database (*.accdb) from within a Python script. Using win32com and Dispatch I can call the application. However, I cant find anything on how to create a new database. access = win32com.client.Dispatch('Access.Application') At that point I have no need to put data into the database and I would do this using pyodbc - I simply need to create an empty database. Does somebody has an example on how to do this? Cheers Thomas 回答1: You have an Access application object. Use its DBEngine.CreateDatabase method to create your

How can I access a specific group of bits from a variable?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 03:08:34
I have a variable with "x" number of bits. How can I extract a specific group of bits and then work on them in C? You would do this with a series of 2 bitwise logical operations. [[Terminology MSB (msb) is the most-significant-bit; LSB (lsb) is the least-significant-bit. Assume bits are numbered from lsb==0 to some msb (e.g. 31 on a 32-bit machine). The value of the bit position i represents the coefficient of the 2^i component of the integer.]] For example if you have int x , and you want to extract some range of bits x[msb..lsb] inclusive, for example a 4-bit field x[7..4] out of the x[31..0

MediaCodec and 24 bit PCM

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am successfully using MediaCodec to decode audio, however when I load a file with 24-bit samples, I have no way of knowing this has occurred. Since the application was assuming 16-bit samples, it fails. When I print the MediaFormat, I see {mime=audio/raw, durationUs=239000000, bits-format=6, channel-count=2, channel-mask=0, sample-rate=96000} I assume that the "bits-format" would be a hint, however this key is not declared in the API, and is not actually emitted when the output format changes. I get {mime=audio/raw, what=1869968451,

Oracle.DataAccess mismatch error

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I installed the odp.net 32 bit installation for Visual Studio 2012. I set a reference to the Oracle.DataAccess.dll and my connection to Oracle seems to be working. When I build the project (.net 4) I get the following error. The project is set to build AnyCPU (my workstation is 64 bit and the server where we will ultimately deploy to is 32bit) 'There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference Oracle.DataAcess, Version 4.112.3.0, Culture=neutral,

Finding consecutive bit string of 1 or 0

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to find the length of the longest consecutive bit string(either 1 or 0)? 00000000 11110000 00000000 00000000 -> If it is 0 then length will be 20 11111111 11110000 11110111 11111111 -> If it is 1 then length will be 12 回答1: The following is based on the concept that if you AND a bit sequence with a shifted version of itself, you're effectively removing the trailing 1 from a row of consecutive 1's. 11101111 (x) & 11011110 (x Repeating this N times will reduce any sequence with N consecutive 1's to 0x00 . So, to count the number of

“This application could not be started.” Only when the file is in system32 directory

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I wrote a little piece of software that downloads file from internet, that is, nothing more. My intentions are to use it thru the command line... It works great, but when I place it in C:\Windows\System32\ to actually use it from everywhere I want it doesn't work now... It didn't throw an exception... it just show me this messagebox - http://i.imgur.com/a7rlMgo.png and if I click "Yes" it opens this page in the browser - http://support.microsoft.com/kb/2715633/en-us What should I do to get it working? The code if it is of any use.. : private