Saturday, March 30, 2013
Sunday, March 3, 2013
IEEE-754 (anon. post)
Summary of IEEE-754
This is a summary of what I understand about IEEE-754 notation.
CMIIW ?
For the purpose of explanation, single precision is chosen.
Normalised:
What is being written?IEEE-754 is another way to represent the scientific notation.
Example of scientific notation : 1.00 x 10^5
Where 1.00 represents the fraction part (Mantissa), and 5 represent the exponent part. 10 represents the radix.
Note that the explanation below uses binary.
Notation :
First bit = Sign of the number, 0 as positive, 1 as negative - the 'sign bit'
The next 8 bits = the Exponent part. Represented by 8-bit (in excess-127 format)
FORBIDDEN à 00000000 and 11111111 are forbidden for normalised single precision, will be explained later.
00000000 as an exponent is ONLY FOR DENORMALISED numbers
11111111 as exponent is ONLY FOR INFINITY.
00000000 as an exponent is ONLY FOR DENORMALISED numbers
11111111 as exponent is ONLY FOR INFINITY.
The
last 23 bits = the Fraction part (aka the Mantissa).
The next 23 bits represent the bits to the right of the binary point. To the left of the binary point is always a 1 (strictly for normalised - and therefore it can be disregarded and assumed to be a one).
All 0 (twenty-three 0's) represents the value of 1.0 while all 1 (twenty-three 1's) represents the value of approximately 2.0.
Note : Binary point is the dot between the number of the fraction part,
like a decimal point - but in binary :)
Range :
For negative : From -2.0 x 2^(127) to -1.0 x 2^(-126)
For positive : From 1.0 x 2^(-126) to 2.0 x 2^(127)
Example :
1.125 (decimal) in IEEE-754 :
In scientific notation of binary: 1.125 = 1.001 x 2^(0).
Sign : Positive (0)
Fraction part : 1.001 (2^0 + 2^(-3))
Exponent part : 0
Solve the Exponent part first; exponent part must be in the form of 8-bit excess-127.
0 in 8-bit excess-127 à 10000000
Fraction part à In IEEE-754, ignore the 1 to the left of the binary point, and COPY the numbers to the right of the binary point (001 in this example) and then fulfill the 23 bits requirement (in this case 001 + twenty more 0s).
Therefore the 1.125 in IEEE-754 notation become:
0 10000000 00100000000000000000000
(Spaces between the sign, exponent and fraction were used to make things more visible)
To make it shorter, convert to Hexadecimal
1.125 in IEEE-754 notation in hexadecimal = 40100000
Note :
For denormalised, all 0 in the fraction part represents the value of 0.0 and all 1 in the fraction part represents the value of approximately 1.0.
Fraction part is ALWAYS BELOW 1.0, exponent part is ALWAYS -126.
Range :
Negative : From 0 to -1 x 2^(-126)
Positive : From 0 to 1 x 2^(-126)
Note : Two zeros exist: +0 and -0.
Smallest possible non zero value à -2^(-23) * 2^(-126) and 2^(-23) * 2^(-126)
Note : There exist positive infinity and negative infinity.
32 bit and 64 bit floating point formats:
The next 23 bits represent the bits to the right of the binary point. To the left of the binary point is always a 1 (strictly for normalised - and therefore it can be disregarded and assumed to be a one).
All 0 (twenty-three 0's) represents the value of 1.0 while all 1 (twenty-three 1's) represents the value of approximately 2.0.
Note : Binary point is the dot between the number of the fraction part,
like a decimal point - but in binary :)
Range :
For negative : From -2.0 x 2^(127) to -1.0 x 2^(-126)
For positive : From 1.0 x 2^(-126) to 2.0 x 2^(127)
Example :
1.125 (decimal) in IEEE-754 :
In scientific notation of binary: 1.125 = 1.001 x 2^(0).
Sign : Positive (0)
Fraction part : 1.001 (2^0 + 2^(-3))
Exponent part : 0
Solve the Exponent part first; exponent part must be in the form of 8-bit excess-127.
0 in 8-bit excess-127 à 10000000
Fraction part à In IEEE-754, ignore the 1 to the left of the binary point, and COPY the numbers to the right of the binary point (001 in this example) and then fulfill the 23 bits requirement (in this case 001 + twenty more 0s).
Therefore the 1.125 in IEEE-754 notation become:
0 10000000 00100000000000000000000
(Spaces between the sign, exponent and fraction were used to make things more visible)
To make it shorter, convert to Hexadecimal
1.125 in IEEE-754 notation in hexadecimal = 40100000
Denormalised
Basically
the same as normalised. However, exponent part is ALWAYS 00000000.
Although in excess-127 00000000 is considered to be -127, FOR
denormalised form, 00000000 indicates that the exponent is -126, but the
number to the left of the binary point of the fraction part is ALWAYS
0.Note :
For denormalised, all 0 in the fraction part represents the value of 0.0 and all 1 in the fraction part represents the value of approximately 1.0.
What can be written with denormalised?
Example : 0.001 x 2^(-126)Fraction part is ALWAYS BELOW 1.0, exponent part is ALWAYS -126.
Range :
Negative : From 0 to -1 x 2^(-126)
Positive : From 0 to 1 x 2^(-126)
Note : Two zeros exist: +0 and -0.
Smallest possible non zero value à -2^(-23) * 2^(-126) and 2^(-23) * 2^(-126)
Infinity
Basically the same thing except the exponent part is 11111111 with all 0 as fraction part.Note : There exist positive infinity and negative infinity.
32 bit and 64 bit floating point formats:
Saturday, March 2, 2013
handy summary of digital Number formats:
one of my fellow students posted (anon.) this handy summary of
digital Number formats:
-------------------------------------------------------------------
8-bit unsigned
Range : 0 to 255
Note : Always positive . Start from 00000000 (0) to 11111111 (255).
Example :
69 = 01000101
8-bit signed magnitude
Range : -127 to 127
Note : Two zeros, +0 (00000000) and -0 (-00000000).
MSB is only the positive or negative sign, with 0 as positive and 1 as negative, contain no value.
Start from 10000000 (-127) to 01111111 (127).
Example :
+69 = 01000101
-69 = 11000101
8-bit One's Complement
Range : -127 to 127
Note : Two zeros, +0 (00000000) and -0 (11111111).
MSB is always negative and has value of -127. Start from 10000000 (-127) to 01111111 (127).
Example :
+69 = 01000101
-69 = 10111010
How to get this from signed number (!!) :
If MSB of signed number is 0 (positive), same as signed number
If MSB of signed number is 1 (negative), keep MSB as 1, invert the rest of the bits.
NB. on my current practice exam questions there are a number of questions such as the following:
Which of the following statements about the 8 bit binary number 10001111 is true ?
a) the number is odd when considered to be in signed magnitude, 2's complement, 1's complement, or excess 128 bit formats.
In general a binary number ending in a zero is usually even unless it is in 1's complement format and its negative, in which case ending in a zero will cause it to be negative and a bin number ending in 1 will be positive, but for all other cases , as per normal - a bin ending in 0 will be even and ending in a 1 will be negative.
8-bit Two's Complement
Range : -128 to 127
Note : -128 written as 100000000, only one zero; +0 (00000000).
MSB is always negative and has value of -128. Start from 10000000 (-128) to 01111111 (127).
Example :
+69 = 01000101
-69 = 10111011
How to get this from signed number (?) :
If MSB of signed number is 0 (positive), same as signed number
If MSB of signed number is 1 (negative), keep MSB as 1, invert the rest of the bits, add 1 to the LSB.
Addition in 2's compliment format
when adding bit sequences (on paper) and you have a 'carry bit' on the left at the MS end
(most significant end) you can simply discard this carry bit.
8-bit excess-128
Range : -128 to 127
Note : From decimal number, add 128 to the value and write the 8-bit unsigned.
Start from 00000000 (-128) to 11111111 (127).
Example :
+69 = 69 + 128 = 197 = 11000101
-69 = -69 + 128 = 59 = 00111011
Binary to Octal/Hex and vice versa
Start from the right hand side (or the least significant bit) and group the bits in groups of three for octal, and four for hexadecimal. Then treat each group as an individual binary string and the result is the
Octal/Hexadecimal representation.
For Binary strings that don't divide evenly into groups of three or four, just add as many zeros as needed to the left side.
Example :
1000101 can become 001 | 000 | 101 for the purpose of conversion (note the
added zeros to the left side)
Hence 69 (or 1000101) is 105 in Octal.
To convert Octal or Hexadecimal to Binary, all you need to do is expand each character into the appropriate number of binary digits (three for octal or four for Hex)
Also, if you want to convert from Hex to Octal or vise-versa, the easiest
way to do it is use conversion to binary in between.
digital Number formats:
-------------------------------------------------------------------
8-bit unsigned
Range : 0 to 255
Note : Always positive . Start from 00000000 (0) to 11111111 (255).
Example :
69 = 01000101
8-bit signed magnitude
Range : -127 to 127
Note : Two zeros, +0 (00000000) and -0 (-00000000).
MSB is only the positive or negative sign, with 0 as positive and 1 as negative, contain no value.
Start from 10000000 (-127) to 01111111 (127).
Example :
+69 = 01000101
-69 = 11000101
8-bit One's Complement
Range : -127 to 127
Note : Two zeros, +0 (00000000) and -0 (11111111).
MSB is always negative and has value of -127. Start from 10000000 (-127) to 01111111 (127).
Example :
+69 = 01000101
-69 = 10111010
How to get this from signed number (!!) :
If MSB of signed number is 0 (positive), same as signed number
If MSB of signed number is 1 (negative), keep MSB as 1, invert the rest of the bits.
NB. on my current practice exam questions there are a number of questions such as the following:
Which of the following statements about the 8 bit binary number 10001111 is true ?
a) the number is odd when considered to be in signed magnitude, 2's complement, 1's complement, or excess 128 bit formats.
In general a binary number ending in a zero is usually even unless it is in 1's complement format and its negative, in which case ending in a zero will cause it to be negative and a bin number ending in 1 will be positive, but for all other cases , as per normal - a bin ending in 0 will be even and ending in a 1 will be negative.
8-bit Two's Complement
Range : -128 to 127
Note : -128 written as 100000000, only one zero; +0 (00000000).
MSB is always negative and has value of -128. Start from 10000000 (-128) to 01111111 (127).
Example :
+69 = 01000101
-69 = 10111011
How to get this from signed number (?) :
If MSB of signed number is 0 (positive), same as signed number
If MSB of signed number is 1 (negative), keep MSB as 1, invert the rest of the bits, add 1 to the LSB.
Addition in 2's compliment format
when adding bit sequences (on paper) and you have a 'carry bit' on the left at the MS end
(most significant end) you can simply discard this carry bit.
8-bit excess-128
Range : -128 to 127
Note : From decimal number, add 128 to the value and write the 8-bit unsigned.
Start from 00000000 (-128) to 11111111 (127).
Example :
+69 = 69 + 128 = 197 = 11000101
-69 = -69 + 128 = 59 = 00111011
Binary to Octal/Hex and vice versa
Start from the right hand side (or the least significant bit) and group the bits in groups of three for octal, and four for hexadecimal. Then treat each group as an individual binary string and the result is the
Octal/Hexadecimal representation.
For Binary strings that don't divide evenly into groups of three or four, just add as many zeros as needed to the left side.
Example :
1000101 can become 001 | 000 | 101 for the purpose of conversion (note the
added zeros to the left side)
Hence 69 (or 1000101) is 105 in Octal.
To convert Octal or Hexadecimal to Binary, all you need to do is expand each character into the appropriate number of binary digits (three for octal or four for Hex)
Also, if you want to convert from Hex to Octal or vise-versa, the easiest
way to do it is use conversion to binary in between.
Tuesday, February 26, 2013
CREDIT APPLICATION
I have applied for credit for 1st yr Comp Science at the University of QLD,
and I hope to continue with second yr subjects.
and I hope to continue with second yr subjects.
Monday, December 24, 2012
Computer Science Semester 2 results
Final Uni results !
Math 1A HD
Math Fund B HD
Statistical Data Analysis HD
Professional Skills Dn
very happy with these !!!
Merry Xmas !!
Math 1A HD
Math Fund B HD
Statistical Data Analysis HD
Professional Skills Dn
very happy with these !!!
Merry Xmas !!
Wednesday, November 21, 2012
heres a cool trick i learnt regarding infinite decimal numbers -
ie
3.711711711711711711.....
let S = 3.711711711...
S= 3 + 711/1000 + 711/1000^2 + 711/1000^3....
see the pattern - the "ratio" is 1:1000 each time, each element in the series.
therefore 1000.S = 3711 + 711/1000 + 711/1000^2 + 711/1000^3....
1000.S - S = 3711- 3 (the infinite recurring decimals subtract and are removed from the picture)
999 S = 3708
S = 3708/999 or 412/111
pretty nifty !
ie
3.711711711711711711.....
let S = 3.711711711...
S= 3 + 711/1000 + 711/1000^2 + 711/1000^3....
see the pattern - the "ratio" is 1:1000 each time, each element in the series.
therefore 1000.S = 3711 + 711/1000 + 711/1000^2 + 711/1000^3....
1000.S - S = 3711- 3 (the infinite recurring decimals subtract and are removed from the picture)
999 S = 3708
S = 3708/999 or 412/111
pretty nifty !
Saturday, November 3, 2012
second semesters exams just around the corner ! : O
this had been a really tough semester ! the work isn't too hard - but there is so much of it.
The math has been really fun.
Project/Team Management not so much since my team are a bunch of lazy ass teenagers...sheesh...
Statistics...its ok.
Here's a breakdown of the Maths we've covered.
* Proof of Pythagoras
* Trig ratios
* Natural Numbers, integers, Rational Numbers
* Proof root(2) is not a fraction
* Real Numbers as infinite decimals
* Intervals, closed and open notation
* Domain and range of a function
* Inverse trig functions
* The unit circle
* Elementary trig properties
* Periodicity of sin cos and tan
* Graphing of Functions
* Slope of a line between two points
* Average velocity for positions given in terms of time
* Instantaneous velocity defined as a limit.
* Derivatives, elementary calculus
* Polar coordinates
* Addition formulae for angles, double and half angle formulae
* Addition of two wave functions
* Modulus
* The Product Rule for differentiation of two functions
* The Chain Rule for Differentiation
* Trig identities and Simplifications
* Polynomials / RemainderTheorem
* Factorisation of Polynomials
* Completion of the square
* Leibniz Notation
* Implicit differentiation
* Differentiation of sin(x) and thus other trig ratios including powers and multiple angles
* Complex numbers, modulus of and argument of.
* Properties of modulus and complex conjugate of a complex number
* De Moivere's Theorem
* Square and Cube roots of complex numbers
* Relation to factoring polynomial functions
* Simple harmonic Motion
this had been a really tough semester ! the work isn't too hard - but there is so much of it.
The math has been really fun.
Project/Team Management not so much since my team are a bunch of lazy ass teenagers...sheesh...
Statistics...its ok.
Here's a breakdown of the Maths we've covered.
* Proof of Pythagoras
* Trig ratios
* Natural Numbers, integers, Rational Numbers
* Proof root(2) is not a fraction
* Real Numbers as infinite decimals
* Intervals, closed and open notation
* Domain and range of a function
* Inverse trig functions
* The unit circle
* Elementary trig properties
* Periodicity of sin cos and tan
* Graphing of Functions
* Slope of a line between two points
* Average velocity for positions given in terms of time
* Instantaneous velocity defined as a limit.
* Derivatives, elementary calculus
* Polar coordinates
* Addition formulae for angles, double and half angle formulae
* Addition of two wave functions
* Modulus
* The Product Rule for differentiation of two functions
* The Chain Rule for Differentiation
* Trig identities and Simplifications
* Polynomials / RemainderTheorem
* Factorisation of Polynomials
* Completion of the square
* Leibniz Notation
* Implicit differentiation
* Differentiation of sin(x) and thus other trig ratios including powers and multiple angles
* Complex numbers, modulus of and argument of.
* Properties of modulus and complex conjugate of a complex number
* De Moivere's Theorem
* Square and Cube roots of complex numbers
* Relation to factoring polynomial functions
* Simple harmonic Motion
* Defn of natural log as the area under the graph of 1/x for x> 0
* graphing Exponential functions
* Decay / Half life
* Decay / Half life
* Complex exponentials and their relation to trig functions
* Hyperbolic functions
* Derivatives of the inverse trig functions
* Local and Global maxima and minima, how to find them if they exist
* Vectors in R2 and R3 from both geometric POV and algebraic POV
* Length and dot product of vectors
* Length and dot product of vectors
* Angle between vectors, Orthogonality
* Parallel and perpendicular vectors
* Vector Cross Product
* Equations of lines and planes in R3
* Find a plane through 3 given non collinear points
* Row operations and simultaneous Equations
* Continuity on a point and on an interval.
* Max and min for continuous functions on closed bounding intervals
* Mean Value theorem, and consequence of a positive derivative
* Rolle's Theorem as a special case
* Verbally posed max min problems
* Snell's Law
* Intermediate Value Theorem
* Approximate Solutions by repeated bi-sections
* Distance between two parallel lines.
* Indefinite integration - example of falling body under constant gravity
* Differential eqn's for Projectiles
* Geometric Sequence and its limit
* Summation
* Parametric curves in the plane
* Slope and equation of the tangent line
* Power Series
* Gregory Series
* Maclaurin Series
* Binomial Series
* Escape Velocity under the inverse square law of attraction
Subscribe to:
Posts (Atom)
