How do I know the number of bits in a byte? - byte

What is the formula for calculating the number of bits in a byte? What external resources can I find more information?

There are 8 bits in a byte. Check here for more information. Please do research before posting a question. This could have been easily googled.

Related

How is it possible to have 0 bits per character?

I have an example of a string ABABABAB and I have to calculate an entropy of this string.
It's obvious that i can get different numbers when taking different alphabets. When I took alphabet A={a,b} I got an answer for entropy = 1 bit per character(Using Shannon's formula) => means 8 bits for a whole string.
But what about a case when we take A={ab,aa,bb,ba}?
We get entropy =0 bits per character (which is also obvious,as there is no randomness). How is it possible to have 0 bpc ? So the whole string = 0 bits?=/ I can't understand where I got wrong..
Thanks in advance for any kind of help.
Yes, it's possible, but other information needs to be sent. In particular that there are four encoded symbols, and that the only possible symbol is AB. Once you've sent those things, the remainder is zero bits.

Checksum algorithm reverse engineering

I've been analyzing some SPI EEPROM memory, and tried to find out which Checksum algorithm has been used;
For example I've got data:
14567D9h and checksum 187h. Assuming it's normal 16 bit check sum I've got 86h - no match, but after adding 101h it magically changes to 391h
Another Example:
8ADh and check sum B5h with this one is normal - 16 bit checksum results with exact number: B5h (perfect match)
I've checked it with 28 samples i was able to intercept. For some values i have to add 101h to checksum and for some it is only needed to sum it up.
Parity check doesn't fit - if you want I can share some more data - all gathered in one excel file, and calculated. After few days of brainstorm with my friend we haven't come up with anything :/
Maybe there is some additional part in the Algorithm, which i haven't found out yet?
CRC and tonnes of other algorithms were checked - only 16 bit checksum was giving any promising results
Thanks for help in advance!
copy of my spreadsheet: https://drive.google.com/file/d/0B2FO0-Y1n-ySMUZ2VTVkME9tdm8/view?usp=sharing
From what I know, CRC is used for files to help identify file' corruption.
The size of the CRC is fixed while the size of the file is not, and the file' size is much bigger.
In other word, the CRC is not reversible simply because it is a many-to-one relation.

Obtaining the position of the first active bit in a string of bits in only one operation

The first question would be:
Is possible to get the position of the first active bit in a string of bits in only one operation ?
An the second of course: How to do it ?
Thanks in advance.
I have heard there are some processors where getting the highest bit of an integer is a single instruction, but I can not name which ones. Even if there are such processors, you will only be able to get the highest bit of an integer not of an arbitrary binary number, which seems to be the case in your question.
For longer bit sequences I don't think you have any better option than to check for each bit, while for shorter ones you may precompute the highest bit values(for instance have an array storing the highest bit for all numbers up to 32768) and than simply get a value from that array to have the answer you need for all up to 15 bit sequences.

Understanding numbers in PE

From the above graphs I know there are 9 sections,but why in the 1st graph it shows 0900?
How to read numbers in PE format?
The number is little endian, so the least significant byte comes first. Reverse the bytes to get the value in the order usually used by people, i.e. 0x0009.
I believe Matti Virkkunen answered your question. If you have any more questions regarding the format I have included the link to the specification.
PE COFF Specification
NumberOfSections The number of
sections. This indicates the size of
the section table, which immediately
follows the headers.
-pg 12

Hashing for sparse bit vectors

Does anyone have any good intuition for a good hash function for a sparse bit vector?
To give a concrete example, say I want to hash a 4096 bit integer where the probability of each bit being 1 is 10%.
I want to get some compression in the hash. For example 4096 bits in and 32 bits out. This is just an example to illustrate what I am looking for. Of course, all answers are very much appreciated.
Would a Bloom filter help?
If the bit vector is 2^32 bits, then why not just use a 32 bit integer?
I would just hash the bits as usual by calling
hash<vector<bool>>(...)
if you're using C++0x, or else see boost::hash.

Resources