Thursday, 10 November 2016

Trace Tables


Trace table


Trace tables are used to allow programmers to trace the value of variables as each line of code is executed. The values of the variables are displayed in a table and assist the programmer in identifying any potential errors.

Image result for Trace tablesImage result for Trace tables

Wednesday, 9 November 2016

2' Complement Binary


Representing negative integers


Negative numbers can also be represented in binary. The name of the system most commonly used to represent and handle negative numbers is '2s Complement'. There are two common methods used to figure out how a negative number is stored using 2s complement.
2's Complement

The first technique involves three steps:

Find the positive value

Switch 1s and 0s
Add 1



To represent -116, the following steps would be followed:

1. Find positive 116
128  64   32   16   8   4   2   1
   0    1     1     1    0   1   0   0




2. Switch 1s and 0s
128   64   32   16   8   4   2   1
 0       1     1     1    0   1   0   0
 1       0     0     0    1   0   1   1




3. Add 1

To add one, it is necessary to start at the right hand side of the number. If the number on the right is a 1, move to the next number. Keep moving from right to left until you find a 0.

In this example there is a 0 underneath the number 4. This 0 would become a 1. The 1s that are to the right of the 0 that was found first need to change from being a 1 to a 0:

128   64   32   16   8   4   2   1
  1      0     0     0    1   0   1   1
  1      0     0     0    1   1   0   0




10001100 = -116

Saturday, 5 November 2016

Graphics Exam Questions

1. (a) Figure 1 shows some of the drawing objects available with a vector graphics drawing software package.

Figure 1

(i) Name two properties which are common to Object 1 and Object 2.                    
1 Have the same line colour
2 Have the same fill colour   (2)

 (ii) When a designer creates a drawing, the size of various objects is often increased/decreased/moved as the drawing is being developed. Explain why no distortion occurs in vector graphics when the size of various objects is changed.

This is because vector graphics are stored using mathematical data and not lots of small dots, or pixels, so vector graphics can be scaled and moved without distortion.(2)

(iii) With vector graphics software, each new drawing is created as a set of vectored objects. Each drawing is created and saved in a file format specific to that brand of software. The software has an ‘export’ facility so that a bitmapped version of any drawing can be produced which can then be used as appropriate e.g. included in a word processed document. Why is this arrangement preferable to bitmapped-based software which only creates and saves a bitmapped file?
It allows you to do more with the graphics so it is more versatile. (1)

(b) Bitmapped software saves the picture as pixels, with a range of different possible colour resolutions as shown in Figure 2.    

  Figure 2


(i) If the graphic is saved as shown as a ‘256 color bitmap’, how many bytes will be used to store each pixel? 1 byte will be used (1)

 (ii) A picture is downloaded from a camera-phone and saved as a ‘256 color bitmap’. The picture has a width of 1280 pixels and height 768 pixels. What is the file size in Kilobytes? 983.04 (1)

 (iii) The same picture as in part (ii) is later loaded into bitmapped software on a PC and saved to a new file as a ‘16 color bitmap’. What is the size of this file in Kilobytes? 491.52  (1) (Total 8 marks)

2. (a) Figure 1 shows a number of drawing objects from the toolbox of a vector graphics drawing program. Figure 1 Object 1 Object 2 Basic Flowchart Shapes Process Data Internal storage Line-curve connector Decision Predefined process Sequential data Line connector Document Stored data Direct data Wavy connector

(i) For object 1 and object 2, state two properties common to both types of object, which would be recorded when used in a drawing.
1 Same line colour
2 Same fill colour    (2)

(ii) State one other property for object 1 which would be recorded when used in a drawing. Dimensions (1)

(iii) Graphics can be created with either vector graphics software or bit-mapped software. If the graphic is enlarged it may become distorted if created with bit-mapped software but show no distortion if created with vector graphics software. Explain this statement.
Bit mapped graphics software uses pixels instead of the mathematical ratios that that the vector graphics software does so when it is enlarged it will enlarge the pixels because that is the base type it uses. (2)

 (b) Figure 2 below shows the file type options available when saving a file with bit-mapped graphics software. Figure 2 File name: Save as type: Save Monochrome Bitmap (*.bmp;*.dib) 256 Color Bitmap (*.bmp;*.dib) 24-bit Bitmap (*.bmp;*.dib) JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF) GIF (*.GIF) TIFF (*.TIF;*.TIFF) PNG (*.PNG) 16 Color Bitmap (*.bmp;*.dib) Cancel This Picture 16 Color Bitmap (*.bmp;*.dib)

 (i) How many bits are used to store each pixel if the resolution selected is as shown (‘16 color bitmap’)?’ 4 (1)

 (ii) ‘256 color’ images are stored with 1 byte per pixel. Explain this statement.
Each pixel takes 8 bits to reperesent all 256 colours and 8 bits is a byte. (1)

(iii) Read again the statement in part (ii). A picture with size 1024 by 768 pixels is saved as a ‘256 color’ image. Calculate the picture size in Kilobytes.  
786.432Kb (1)

 (iv) Black and white (monochrome) bit-mapped files store each pixel with a single bit. A black and white image of size 512 by 256 pixels has a calculated file size of 16 Kilobytes. The actual file size is larger than this calculated size as the bitmap file contains other data. What is this other data?
The file name and format type (1) (Total 9 marks)

 3. Bit patterns can be interpreted in a number of different ways. A computer word contains the bit pattern 0011 0100. (a) What is its decimal value if it represents: a pure binary integer;
52. (1)

 (b) (i) The ASCII value for the character ‘0’ (zero) is 48. What character is represented by 0011 0100?
the number 4 (1)

 (ii) Name one other standard coding system for coding information expressed in character or text-based form.
Unicode (1)

(c) One method of representing graphics in a computer system is as bit mapped graphics.
 The black line on the left might be represented as (i) Describe how a coloured line might be represented. ............................................................................................................................ ............................................................................................................................ ............................................................................................................................ (2)

 (ii) Describe how a line would be stored using vector graphics. ............................................................................................................................(3) (Total 8 marks)

Progress Assessment one Corrections

Q4) D) There can be a loss of precision when a denary number is stored using this floating point system. The closest possible representation of 6.9 is

0.1101110    0011

By converting this bit pattern back into denary we can see that the actual number is 6.875, not 6.9.
Calculate the absolute error that has occurred.
6.9-6.875=0.025

ii) Calculate the relative error that has occurred.
0.025/6.9=0.0036

Q5) For each of the following, name a suitable data type and give a reason for your choice.
a) The number of books a student has out on loan from the college libary.
Integer - Need to store whole numbers and add or subtract them as he takes is or brings back books.

b)A students average mark to two decimal places.
Single - can handle calculations and numbers with decimals in.

c) Telephone number such as 01223123456.
String - needs to be string and not single or integer so beginning 0 does not disappear.

Q8) This question is based around the pre-released code.

a)Give a line of code where a relational operator is used.
If num < num2 then

d) Give a line of code in which an assignment statement is used.
num1=console.readine

Vector Grapics


What are vector graphics?


Vector graphics are created in graphics packages and consist of shapes called objects.

It is possible to edit each object separately, for example, change the shape, colour, size and position.

Even if an object in a vector graphic is quite large, it doesn't need a lot of computer memory. Therefore the file size of a vector graphic is often very small.

Vector graphics are scalable - ie. when you resize them, they do not lose quality.


Because vector-based images are not made up of a specific number of dots, they can be scaled to a larger size and not lose any image quality. If you blow up a Bitmap graphic, it will look blocky, or "pixelated." When you blow up a vector graphic, the edges of each object within the graphic stay smooth and clean. This makes vector graphics ideal for logos, which can be small enough to appear on a business card, but can also be scaled to fill a billboard. Common types of vector graphics include Adobe Illustrator, Macromedia Freehand, and EPS files. Many Flash animations also use vector graphics, since they scale better and typically take up less space than bitmap images.

What is a vector in animation?

Vector animation is a term used to refer to animation in which the art or motion is controlled by vectors rather than pixels. Vector animation often allows cleaner, smoother animation because images are displayed and resized using mathematical values instead of stored pixel values.

Tuesday, 1 November 2016

VB Loops

Summary

Use a For ... Next loop if we know before entering the loop how many times we want to repeat the group of statements.

Use Do While ... Loop if the group of statements is only to be executed under certain conditions.

Use a Do ... Loop Until when we want to execute a group of statements at least once.

An infinite loop is one that never stops running.

Bits and Byte Prefixes

Nibble = 4 bits
x2 Nibbles = 1 byte = 8 bits
Kb= Kilobit = 1000 bits = 125 bytes
Mb = Megabit = 1,000,000 bits

KB = Kilobyte = 10^3 = 1000 bytes
MB = Megabyte = 10^6 = 1,000,000 bytes
GB = Gigabyte = 10^9 = 1000 MB
TB= Terabyte = 10^12 = 1000 GB

Ki (KiB) = Kibibyte = 2^10 = 1024 bytes
Mi (MiB) = Mebibyte = 2^20 = 1,048,576
Gi (GiB) = Gibibyte = 2^30 = 1024 Mi
Ti (TiB) = Tebibyte = 2^40 = 1024 Gi