Monday, 31 October 2016

Bitmapped Graphics

What are bitmap graphics?

When you take a photograph using a digital camera or scan an image from a magazine, you are creating a bitmap graphic.

A bitmap graphic is composed of many tiny parts, called pixels, which are often many different colours. It is possible to edit each individual pixel.

Since the computer has to store information about every single pixel in the image, the file size of a bitmap graphic is often quite large.

When you resize a bitmap graphic, it tends to lose quality.

Bitmap files are especially suited for the storage of real-world images; complex images can be rasterized in conjunction with video, scanning, and photographic equipment and stored in a bitmap format.

Advantages of bitmap:

Bitmap files may be easily created from existing pixel data stored in an array in memory.

Retrieving pixel data stored in a bitmap file may often be accomplished by using a set of coordinates that allows the data to be conceptualized as a grid.

Pixel values may be modified individually or as large groups by altering a palette if present.

Bitmap files may translate well to dot-format output devices such as CRTs and printers.

Bitmap drawbacks:

They can be very large, particularly if the image contains a large number of colors. Data compression can shrink the size of pixel data, but the data must be expanded before it can be used, and this can slow down the reading and rendering process considerably. 
Also, the more complex a bitmap image (large number of colors and minute detail), the less efficient the compression process will be.

They typically do not scale very well. Shrinking an image by decimation (throwing away pixels) can change the image in an unacceptable manner, as can expanding the image through pixel replication. Because of this, bitmap files must usually be printed at the resolution in which they were originally stored.

Bitmap graphics software

Bitmap graphics can be created and edited using packages such as:
  • Microsoft Paint
    Adobe Photoshop

Tuesday, 25 October 2016

Daily Dose Practice Exam questions

Q1. 

(a)     Explain the difference between hardware and software.
Hardware is the physical components parts of the computer. Example of a piecie of hardware is the computer motherboard.
Software is the program and code or instructions that the computer is given to use.

(b)     (i)      Which of the following is a typical value for the clock speed of a processor?
512 MB         128 kbps              80 GB           2 Mb/s             3.0 GHz
(circle your answer)
(ii)     Which of the following is a typical value for the capacity of a memory card for use with a digital camera or other device?
512 MB         256 bits/sec         50 GB           2 bytes            3.0 GHz
(circle your answer)
Q2.
A program has been written to analyse the results of a survey.  For each of the following, name a suitable data type and give a reason for your choice:
(a)     number of cars owned by a household;
data type: Integer
reason: Dealing with whole numbers only





(b)     a telephone number such as 0122456789;
data type: String
reason: So leading zeros do not dissapear and because it will not need calculations preforming on them.





(c)     whether a household’s accommodation has central heating or not,
data type: Boolean

reason: It is a yes or no question






(d)     the average number of cars owned by the households.
         data type: floating point

reason: Average may not be an whole number



Q3.
Convert the denary value 61 into
(a)     binary= 111101
(b)     hexadecimal= 3D


Q4.
A computer program contains the following fragment:
Boolean: LY
Integer: Y
¼
LY := (Y mod 4 = 0)  AND ( NOT (Y mod 100 = 0) OR (Y mod 400 = 0) )
(The function A mod B returns the remainder when A is divided by B, eg. 11 mod 3 returns the value 2.)
(a)     What is meant by a Boolean variable? A variable with only two possible answers e.g true or false.


(b)     What value would be assigned to the variable LY, if the variable Y contains
(i)      1999?----


(ii)     2000?----
Q5.
How many bits make up one byte? 8






Q6.
Using a High Level Language with which you are familiar, give one example of each of the following.
(a)     Data assignment. A=b+c
 (b)    Selection (Conditional step) If A=8 Then "Good"
 (c)    Repetition (Iteration) If A<8 then A=A+1





Q7. 
(a)     A binary pattern might represent a decimal integer or a decimal real number.  In a computing context, give an example of
(i)      a decimal integer= 65
(ii)     a decimal real number= 34.5656


Daily Dose Practice Exam questions

Q1. 

(a)     Explain the difference between hardware and software.
Hardware is the physical components parts of the computer. Example of a piecie of hardware is the computer motherboard.
Software is the program and code or instructions that the computer is given to use.

(b)     (i)      Which of the following is a typical value for the clock speed of a processor?
512 MB         128 kbps              80 GB           2 Mb/s             3.0 GHz
(circle your answer)
(ii)     Which of the following is a typical value for the capacity of a memory card for use with a digital camera or other device?
512 MB         256 bits/sec         50 GB           2 bytes            3.0 GHz
(circle your answer)
Q2.
A program has been written to analyse the results of a survey.  For each of the following, name a suitable data type and give a reason for your choice:
(a)     number of cars owned by a household;
data type: Integer
reason: Dealing with whole numbers only




(b)     a telephone number such as 0122456789;
data type: String
reason: So leading zeros do not dissapear and because it will not need calculations preforming on them.




(c)     whether a household’s accommodation has central heating or not,
data type: Boolean

reason: It is a yes or no question





(d)     the average number of cars owned by the households.
         data type: floating point

reason: Average may not be an whole number


Q3.
Convert the denary value 61 into
(a)     binary= 111101
(b)     hexadecimal= 3D


Q4.
A computer program contains the following fragment:
Boolean: LY
Integer: Y
¼
LY := (Y mod 4 = 0)  AND ( NOT (Y mod 100 = 0) OR (Y mod 400 = 0) )
(The function A mod B returns the remainder when A is divided by B, eg. 11 mod 3 returns the value 2.)
(a)     What is meant by a Boolean variable? A variable with only two possible answers e.g true or false.


(b)     What value would be assigned to the variable LY, if the variable Y contains
(i)      1999?----


(ii)     2000?----
Q5.
How many bits make up one byte? 8





Q6.
Using a High Level Language with which you are familiar, give one example of each of the following.
(a)     Data assignment. A=b+c
 (b)    Selection (Conditional step) If A=8 Then "Good"
 (c)    Repetition (Iteration) If A<8 then A=A+1




Q7. 
(a)     A binary pattern might represent a decimal integer or a decimal real number.  In a computing context, give an example of
(i)      a decimal integer= 65
(ii)     a decimal real number= 34.5656


Parity Bits


A parity bit is a single bit added to a binary data transmission used to indicate if whether the 0's and 1's within that data transmission is an even or odd number. The parity bit is used in parity error checking to find errors that may occur during data transmission.

Even parity can be more clearly explained by means of an example. Consider the transmitted message 1010001, which has three ones in it. This is turned into even parity by adding a one, making the sequence 1 1010001, so that there are four ones (an even number). If the transmitted message has the form 1101001, which is already an even number, a zero is added to sustain the even parity. The resulting message is 0 1101001, so that an even number of ones remains in the transmitted message.
Image result for parity bitImage result for parity bit
Even parity checking is also used in testing memory storage devices. However, in order for this to work, the sender and receiver should agree to use even parity checking as the basic error detection technique. If a single bit is switched during transmission, parity checks can detect that the data is corrupted. However, even parity may fail to detect errors introduced when an even number of bits in the same data unit is altered due to electrical noises.

Parity checking is the most basic form of error detection in communications. Although it detects many errors, it is not foolproof, because it cannot detect situations in which an even number of bits in the same data unit are changed due to electrical noise. There are many other more sophisticated protocols for ensuring transmission accuracy.
Parity checking is used not only in communications but also to test memory storage devices. Many PCs, for example, perform a parity check on memory every time a byte of data is read.


Thursday, 13 October 2016

More Floating Point exam questions

Important to remember is that the decimal point must be between a 0 and a 1. 0.1 or 1.0.

Q1) Using a 7-bit mantissa and a 5-bit exponent using 2's complement format write the smallest number that can be represented:
1.000000    10000

b) Work out what the denary number 416 would be as a binary floating point number with a 7-bit mantissa and a 5-bit exponent.
011010000.0=416
0.1101000         01001

c)1.001110        00100
e) Type of error.
 If two large numbers are multiplied together- This will create an overflow.
If a small number is divided by a large number- this will create an underflow

Q2) A floating point number uses a 8-bit mantissa and a 4-bit exponent.
In binary, write the largest positive number that can be represented using this normalised floating point system.
0.1000000  1000

b) Calculate the denary number of this floating point number.
1.0101000     0011 = -5.5

c) Write the normalised floating point representation of the denary value 13.625 in the boxes below.
01101.101
0.1101101       0100

d) Write the normalised floating point number of the denary value 0.34375 in the boxes below.
0.1011000 1111

e)Explain what overflow is and give an example of a situation which might cause overflow to occur?
When there is a number that is too big to be represented using given number of bits.

Q3) a) The binary pattern 1001 1000 0100 can be interpreted in a number of different ways?
Hexadecimal- BCD
Decimal- 9  8  4

Tuesday, 11 October 2016

Floating Point Exam questions

Q1. A normalised floating point representation uses an 8-bit mantissa and a 4-bit exponent, both stored using 2's Complement format.

In binary write the smallest number that can be represented using this format.
Mantissa-0.1000000
Exponent-1000

B) This is a floating point representation of a number:
1.011000     0010 
Calculate the denary equivalent of the number. 
Answer= -2.5


C) Write the floating point representation of the denary number 12.75
0.1100110     0100

D) Floating point numbers are usually stored in normalised form.
State two advantages of using a normalised representation.
Advantage 1- It is a more precise way of representing values.
Advantage 2- Numbers take up less storage space so more can be stored.

An alternative twos's bit complement format representation is proposed. In the alternative representation 7 bits will be used to store the mantissa and 5 bits will be used to store the exponent. 

Existing representation (8-bit mantissa, 4-bit exponent)
Proposed alternative (7-bit mantissa, 5-bit exponent)
Using a 7-bit mantissa and a 5-bit exponent will allow the decimal point to be moved farther allowing smaller, or larger numbers to be represented. However only having a 7-bit mantissa will restrict you on the accuracy of smaller numbers because there is less bits to work with. This means that some accuracy may be lost.

Sunday, 9 October 2016

Floating Point Numbers


• What kind of rounding error can occur in Denary?

There is a problem with rounding when we have recurring numbers like 1/3. We have 0.333333333333...If we add 1/3+1/3+1/3 them we usually round it to 1. even though we know it is 0.99999999.




• What kind of rounding error may happen in Binary?

In binary if you have a recurring number like 1/3 then the computer will eventually run out of bits to store the 1/3 so it will not truly be 1/3. this means there will be tiny errors in calculations where numbers cannot properly be represented and the computer has to round to give what is thinks is the correct answer.




• Why use Floating Point? 

We use Floating point because it is is much more efficient. This means it takes up less space to store the numbers and it is much easier for the computer to do calculations so it is much faster.

\underbrace {\overbrace {0}^{{\text{sign bit}}}\cdot 101010101}_{{\text{mantissa}}}\times \underbrace {010101}_{{\text{exponent}}}

• What is meant by the mantissa? What is meant by the exponent?


The first bit defines the non-zero part of the number and is called the Mantissa, the second part defines how many positions we want to move the decimal point, this is known as the Exponent and can be positive when moving the decimal point to the right and negative when moving to the left.
Both the mantissa and the exponent is in twos complement format. So if there is a 1 present in the leftmost bit of the mantissa, then this is a negative binary number.

• Can you convert the following 6 bit mantissa and 4 bit exponent into denary 0.10100 0100?

01010.0
=10,0



Monday, 3 October 2016

Decimal Numbers in Binary


How to covert Decimal numbers such as 3.5, 6.625 or 0.25.



Set up the problem. For this example, let's convert the decimal number 15610 to binary. Write the decimal number as the dividend inside an upside-down "long division" symbol. Write the base of the destination system (in our case, "2" for binary) as the divisor outside the curve of the division symbol.



Divide. Write the integer answer (quotient) under the long division symbol, and write the remainder (0 or 1) to the right of the dividend.
Since we are dividing by 2, when the dividend is even the binary remainder will be 0, and when the dividend is odd the binary remainder will be 1.


Continue to divide until you reach 0. Continue downwards, dividing each new quotient by two and writing the remainders to the right of each dividend. Stop when the quotient is 0.


Write out binary number. Starting with the bottom remainder, read the sequence of remainders upwards to the top. For this example, you should have 10011100. This is the binary equivalent of the decimal number 156. Or, written with base subscripts: 15610 = 100111002
This method can be modified to convert from decimal to any base. The divisor is 2 because the desired destination is base 2 (binary).

IF Statements

Programs don’t always run in SEQUENCE and require an element of SELECTION. SELECTION means that part of the code may be executed depending upon a CONDITION being met.

Conditions are made up as follows:

            Variable/Value   Relational-Operator   Variable/Value

Relational Operators are as follows:

            =          Equal To
            <          Less Than
            <=        Less Than or Equal To
            >          Greater Than
            >=        Greater Than or Equal To
            <>        Not Equal To

Statements Used

IF Condition Then
End IF
















This is an example of the work from the Statements worksheet. It shows the use of IF and End |IF. A number is inputted and then the conditions that are met show up. so the number is between 1-20 for example.