What is the size of a bitmap image which is 80px by 70px with 16 different colors? - bmp

This is a question in my coursebook and the answer says 2800 bytes.
I have not been able to find anything on how to calculate this.

It's (70 * 80 * 4) / 8 which gets you the 2800 bytes.
The explanation is simple enough. You've got 70 * 80 == 5600 different bits in your image. Those bits can be either one of the 16 colours. To store the possiblity of 0-15, we need 4 bits, that lead to 2^4 == 16 combinations.
So (70 * 80 * 4) will give you the filesize in bits, divide that by 8 (8 bits in a byte) and you've got your result.

I'm guessing it would work like this
70*80 = 5600
Since each pixel can be one of 16 colours, each pixel can be fit in 4 bits (16 number combinations)
Therefore, you divide 5600 by 2 (8 bits in a byte) and get 2800!

Related

How does Matlab store this large of a number with only 64 bits?

The largest number in double precision (that is, 64 bit) floating point arithmetic is
1.111...110 x 2^(512) (where there are 51 1's after the radix point). This number is less than 2 x 2^(512) == 2^(513) == 8^(171) < 10^(171). Therefore, when I assign x = 10^(171), I expect that x will be stored as Inf. However, this is not the case. Calling x in the interactive console displays 1.0000e+171. The only explanation I could think of is that Matlab uses more than 64 bits to store x. But a quick check of whos x reveals that x is stored in 8 bytes.
In fact, the largest power of 10 which will not be stored as Inf is 10^308.
Can someone please explain what is going on here?
I'm sorry, I made a simple mistake here. In 64 bit arithmetic, 11 bits are used to encode the exponent. Therefore we have 2^(11) = 2048 possible exponents, and so they range from -1023 to 1024, not from -511 to 512 like I thought. Therefore the largest number in 64 bit arithmetic is $1.111...110 x 2^(1024)$, which is in fact (with the exponent having 3 significant digits) 10^(308.6), corroborating my experimental results.

Adding MSB and LSB to get 0-511

I'm trying to get 9 bits out of a MIDI controller. According to the manual, the position of a fader on the MIDI controller is sent out as 9 bits, which would make it 0-511.
In my software (Max/MSP), the MSB comes in as only 7 bits (0-127) and the LSB flickers between 0/64 generally and occasionally I see 32 and 96.
I think I need to do some bit shifting and then add the MSB and LSB somehow to get the full 0-511.
Any ideas?
from the manual:
MSB=0 M M M M M M M
LSB=0 L L 0 0 0 0 0
The position is sent out with 9 bits of accuracy. The 2 least significant bits can be ignored for 7-bit accuracy.
MIDI data values can only use 7 bits, so it's spread the most significant 7 to that first CC data byte, and the last couple bits to the next CC data byte.
If you convert the least significant bits, possible values are 0, 32, 64, and 96 as you have seen. But of course, those aren't meant to be taken out of context.
Assemble your bits like this:
0000 000M MMMM MMLL

Computational arithmetic - how many bits exactly for 8 digit number needed

how many bytes (and how many bits) you need to represent number 99999999 ?
I need to know this: we have a calculator, the simplest possible, and can accommodate up to 8 digits, i.e. from 0 to 99999999 (let's forget the negatives, unless if you feel comfortable to include in your answer).
How many bits/bytes do we need to store values from 0 up to and inclusive 99999999 ?
I appreciate your help, kindly provide the theoretical background and any calculations if you can.
Thank you very much!
Because there are 8 digits and each digit can have 10 values (0, 1, …, 9), the total number of representable numbers is 10^8. To represent this many numbers in binary, we must have a number of digits N such that assigning just one of two values (0, 1) to each position gives at least as many representable numbers as we have in decimal. That is, we have to solve
2^N >= 10^8
We can take the base-2 log of both sides to get
N >= log_2(10^8) = 8 * log_2(10)
At this point, hopefully you have a calculator handy to calculate log_2(10). Note that this is equal to log_10(10)/ log_10(2) = 1/log_10(2), if your calculator does logarithms in base 10 by default. The answer comes out to:
N >= ~26.58
The smallest integer value of N that satisfies this is 27. So, 27 digits are required.
Short answer is 27 bit, or 4 bytes which cover 32 bits.
Longer answer is: you have to represent 10^8 values, so log2(10^8) roughly 26.575424759. Ceil this value, and you see 27. Ceil 27 with groups of 8 bits, and you have 32 bits, 4 bytes

How many words fit in 4 bits

I have 2 questions that I would like to get helped with.
First question is: If you have 4 bits, how many unique numbers can you write?
Second question is: If you have 4 bits, what is the largest number you can write. Answer with the base 10
Appreciate any help!
Edited - nothing really
Answer 1) With the 4 bits we can write 16 different numbers. As we have 4 different position of bits let's say ABCD where A,B,C,D are representing 1 bit. Each position A,B,C,D has two possible input 0 or 1 so each position is having 2 possible inputs.
So for 4 positions total different outputs = 2*2*2*2 =16 Which also can be understood by permutation which is equal to 2^(no.of bits) .Here 2^(4) which is equal to 16.
Answer 2) Mamimum number having n bits is always all bits as 1s so for n bit number, maximum number which can be formed is all n 1s.
So for 4 bit number, Maximum number which can be formed is 4 1s in binary representation of the number. So here that number is 1111 in binary . In decimal it is 15.
It also can be calculated by 2^(no.of bits) -1. Here number of bits is 4 so maximum number is 2^(4) -1 which is 16-1= 15
Is this your college assignment or sth?
The answer is simply,
if you have n bits, you can have 2^n unique numbers.
The largest number you can write is n 1's.
i.e. For four bits,
Number of unique numbers = 2^4 = 16
The largest number = 4 1's = 1111 = F (hex) = 15 (Base 10)

Convert from base10 to base8

Converting from base-10 to base-8 is a little trickier,
but still straightforward. We basically have to reverse the process from above. Let's start with an example: 150 of base-10.
We first find the largest power of 8 that is smaller than our number. Here, this is 82 or 64 (83 is 512). We count how many groups of 64 we can take from 150. This is 2, so the first digit in our base-8 number is 2. We have now accounted for 128 out of 150, so we have 22 left over.
The largest power of 8 that is smaller than 22 is 81 (that is, 8). How many groups of 8 can we take from 22? Two groups again, and thus our second digit is 2.
Finally, we are left with 6, and can obviously take 6 groups of one from this, our final digit. We end up with 226 of base-8.
In fact, we can make this process a touch clearer with math. Here are the steps:
150/82 = 2 remainder 22
22/81 = 2 remainder 6
6/80 = 6
Our final answer is then all of our non-remainder digits, or 226.
my question is same way if we want 65 of base-10 to convert to base-8 what happens ?
any help is appreciated..thanks in advance