Thursday, October 18, 2007

Some Basic Points About PHP

Today in class we started to look at some PHP scripting language. initially we will look at the basics but we will soon move on to more complicated stuff.
  1. PHP stands Pre Hypertext Processor
  2. It is a server Scripting language
  3. Its an open source software and
  4. It supports many databases.
A PHP file may contain Text, HTML tags and scripts and the files are returned to the servers as HTML. PHP Extensions are .php , .php3 and .phtml

PHP Syntax



A php file must stat with and end with ?>

echo " hello world"
will reproduce Hello world in the browser.

Variables are declared as
$var_name = "value"

Sunday, October 14, 2007

Thinking About the Program

Today i started properly to think about how the program of pEters Petrol Pumps is going to work. I used the guidelines to think about how the program is going to work including the interfaces and the acutal program.

Thursday, October 4, 2007

Task 24

A 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponent. Convert the number 1010011010000111 into decimal by filling in the following table to guide you:

The number is negative. I know this because:
The first digits are 10

The mantissa (with the decimal place inserted) is:
1010011010

The exponent is:
000111

The decimal point in the mantissa must now be moved:
7 places to the right

The mantissa becomes:
1011001.10

Removing unnecessary zeros gives:
1011001.1

Converting from a negative fixed point binary number into denary gives the final answer as:
89.5

Task 23

A 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponent. Convert the number 1010110000000011 into decimal by filling in the following table to guide you:

The number is negative. i know this because:
The first digits are 10

The mantissa (with the decimal place inserted) is:
1.010110000


The exponent is:
000001

The decimal point in the mantissa must now be moved:
1 place to the right.

The mantissa becomes:
1.010100000

Removing unnecessary zeros gives:
1.0101

Converting from a negative fixed point binary number into denary gives the final answer as:
-1.00625

Task 22

A one byte floating point numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number -4 into a normalised floating point number by filling in the following table:

+4 in binary is:
100

Packing the front of the binary answer in step 1 with zeros to get the mantissa to the correct size( 5 digits) gives:
00100

The 2s compliment for of the answer to step 2 is:
11011

Moving the decimal point in the answe to step 3 to the correct place for the normalised form gives:
11.010

Removing excess 1s from the front of the number and adding extra zeros at the back of the number to get the normalised form gives us:
1.0100

To get the decimal place of the normalised form answer in step 5 back to its pre-normalised position, the decimal point needs to be moved:
3 places to the right.

The exponent is therefore:
011

Putting the mantissa and the exponent together gives the final answer as:
10100011

Task 21

A one byte floating point numbering system uses 5 places for the matissa and 3 for he exponant. Convert the number -1.5 into a normalised floating number by filling in the following table.

+1.5 in binary is:
1.1

Packing the front of the binary in STEP1 with zeros to get the mantissa to the correct size gives:
0001.1

The 2s comliment form of the answer in step 2 is:
1110.1

Removing excess 1s from the front of the number and adding extra zeros at the back of the number to get the normailsed form gives us:
1.0100

To get the decimal place of the normilaised form answer in STEP 5 back to its pro-normilised position, th edecimal point needs to be moved:
1 place to the right

The exponant is therefore:
001

Putting the mantissa and the exponant together gives the fimal answer of:
10100001

Task 20

aonebyte floating poimt numbering system ses 5 places of the mantissa and 3 places for the exponant. COnvert the number 10011111 into decimal by filling in the following table.

This number is negitive because:
The first digits begin with 10

The mantissa (with the decimal place inserted) is:
1.0011

The mantissa converted into a negitive binary number that is not in 2s compliment is:
0.1101

The exponant is:
111 = -3

The mantissa now becomes:
0.0001101

Removing unneccessary zeros gives:
0.0001101

Converting from a negitive fixed point binary number into a denary givs the final answer as:
-0.1015625

Task 19

A one byte floating numbering system esus 5 places for the mantissa and 3 for hte exponant. Calculate the number 10111010 into decimal by filling int he following table.

This number is negitive. I know this because:
The first digits are 10

The mantissa (with the decimal place inserted) is:
1.0111

The mantissa converted into a negitive binary number that is not in 2s compliment is:
0.1001

The decimal point in the mantissa must no be moved:
2 places to the right

The mantissa now becomes:
010.01

Removing unneccessary zeros gives:
10.01

Converting from a negitive fixed point binary number into denary gives the final answer of:
2.25.

Task 18

a 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponant. Convert the number 2.75 into a normalised floating number using the following table to guide.

Converting 2.75 into a fixed point number gives me:
10.11

The mantissa(with the decimal place inserted) is 10 digits long and nums begin with 0.1. The mantissa is:
0.101100000

To get the mantissa back to the original fixed point number, the decimal place must be moved:
2 places to the right.

The exponant, which is 6 digits long will be :
000010

Putting the mantissa and the exponant together, the final answer is:
0101100000000010

Task 17

A 2 byte floating point numbering system uses 10 places for the mantissa and 6 for the exponant. Convert the number 12.5 into a normalised floating point number using the following table to guide you.

Converting 12.5 into a fixed point number gives me:
1100.1

The mantissa(witht he decimal place inserted) is 10 digits long and must bgin with 0.1. the mantissa is:
0.110010000

To get the mantissa back to the original fixed place number, the decimal place:
Move the decimal place 4 places to the right

Putting the mantissa and the exponent together, the final answer is :
0110010000000100

Tank 16

A 2 byte floating point numbering system uses 10 places for the mantissa and 6 for the exponant. convert the number 0100000000111101 into decimal by filling in the following table.

This number is positive because:
the first digit is a 0

The mantissa(with the decimal place inserted) is:
0.100000000

The exponant is 111101 which os negitive because:
it begins with a 0

The denary equivalant is:
-3

The decimal place should move:
3 places to the left

The mantissa now looks like:
0.0001000000

removing the redunadant zeros gives:
0.0001

The final denary is :
0.0625

Task 15

A 2 byte floating numbering system uses 10 places for the mantissa and 6 places for the exponant. conver the number 0100000000111101 into decimal by filling in the following table.

This number is positive, i know this because:
the first digit is a 0

The mantissa (with the decimal place inserted) is:
0.110000110

The exponant is 0000110 is positive because:
it begins with a 0

The denary equivaland is
+6

The decimal should move :
6 places to the right

The final denary is:
49.75

Task 14

A two byte floating point number system uses 10 places for the mantissa and 6 for the exponent. Convert the number 0111101000000101 into decimal by filling in the following table.

This number is positive. i know that because:
the first digit is a 0

The mantissa(with the decimal place inserted):
0111101000

The exponant is 000101 which is positive because:
the most left digit is a 0

The denary equivalant of 000101 is
+3

The mantissa nw looks like this:
0111100000

Removing the redundant zeros the mantissa looks like:
1111.1

the final denary answer is:
30.5

Wednesday, October 3, 2007

Task 13

A one byte floating numbering system uses 5 places for the mantissa and 3 for the exponant. conver the number 1.5 into a normalised floating-point number.

Converting 1.5 into a fixed oint number gives:
1.1

The mantissa(with the decimal place inserted) is 5 digits long and must negin with 0.1. the mantissa is:
0.1100

To get the mantissa nack tot he original fixed point number, the decimal place must be moved:
one place to the right

The exponant, which is 3 digits long is:
001

Putting the mantissa and exponant together, the final answer is:
01100001

Task 12

A one byte floating numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number 2.25 into a normalised floating nnumber using the following table to guide you.

Converting 2.25 into a fixed point number gives me:
10.01

The mantissa (with the decimal place inserted) is 5 digits long and must begin with 0.1, the mantissa is:
0.1001

to get the mantissa back to the original fixed point number, the decimal place must move:
2 places to the right

The exponant, which is 3 digits long is:
010

Putting the mantissa and the exponant together, the final answer is:
01001010

Task 11

Task 11 - A one-byte floating-point numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number 01110111 into decimal by filling in the following table.

The number is positive, i know that because:
It begins with a zero

The mantissa is:
01110

The exponent is 111 which is negative because:
Begins with a 1

The denary equivalent of 111 is:
-1

The decimal place in the mantissa must be moved LEFT/RIGHT because:
Left because -x moves left and +x moves right

The mantissa now looks like this:
0.0111

Removing redundant zeros, the mantissa now looks like this:
0.0111

The final denary answer is:
1/28 OR 0.4375

Task 10

A one byte flooating point numbering system uses 5 places for the mantissa and 3 for the exponent.Conver the numbner 01100011 into decimal by filling in th following table

This is positive. i know this because:
the first digit is a 0

The mantissa(with decimal place inserted) is:
01100

The exponent is 011 which is positive because
The first digit is 0

The decimal place in th emantissa muct be moved LEFT/RIGHT because
Right because it is positive

The mantissa now looks like:
0110.0

Removing redundant zeros,the mantissa now looks like:
110

The final denary answer is:
6

Has anyone seen Mr Barr?

Mr Barr has gone missing
He left nothin apart for work and this comment

and i will see you on 00001000 00001010

feared dead to return as ghost.

Monday, October 1, 2007

Task 9

Convert these denery numbers into binary using the fixed point number system.

a) 4.75
b) 10.5
c) 7.25
d) 1.125




a) 00100110
b) 01010100
c) 00111010
d) 00001001

Task 8

Convert these fixed point numbers into denary

a) 01111100
b) 00000100
c) 1100001




a) 15.5
b) 0.5
c) 24.125

Task 7

Convert the following 7 bit 2s compliment into decimal.
a)1000100
b)1011000
c)0110001


a)-60
b)-40
c)+49

Task 6

Convert these 2s compliment valsue into their denary values.
a) 10001
b) 11001
c) 00010
d) 01000
e) 11110
f) 01110


a) -15
b) -7
c) 2
d) 8
e) -2
f) 14

Task 5

In using a 5 bit 2s compliment, show how to represent
a) -12
b) -14
c) -1


a) 10100
b) 10010
c) 11111

Task 4

In using a 5 bit 2s compliment, show how to represent
a) -4
b) -11
c) 2


a)11100
b)10101
c)00010

Task 3

In using a 5 bit 2s compliment, show how to represent
a) 4
b) 8
c) 11




a) 00100
b) 01000
c) 01011

Task 2

Suppose you had seven bits to represent 2s compliment numbers.
a)What is the weighing of each bit?
b)What is the largest number that can be represented?
c)What is the smallest number?




a) -64, 32, 16, 8, 4, 2, 1
b) 63
c) -64

Task 1

Suppose you had 3 bits to respresent 2s compliment numbers.
a) What is the weighing of each bit?
b) What is the largest number that can be represented?
c) What is the smallest?




a) -4, 2, 1
b) 3
c) -4