Floating Point (Multiplication) Disusun Oleh: Tri Fena Rohawati (22.05.3770)
Definisi Floating point adalah sebuah format bilangan yang dapat digunakan untuk merepresentasikan sebuah nilai yang sangat besar atau sangat kecil.
Representation of Floating Point Numbers in Single Precission IEEE 754 standard Value = N = (-1)S X 2 E-127 X (1.M) S E M
Representation (cont..) Di mana : S = sign bit (0->positif, 1->negatif) E = Exponent M = Mantissa
Floating point Conversion Example Bilangan desimal 0.7510 akan dikonversikan dalam bentuk IEEE 754 32 bit format…. (0.75)10 0 = 0 (converted into biner) .75 = Calculation Integer Fraction .75 * 2 1 .5 .5 * 2 1 0 Jadi, 0.75 = 11 (0.75)10 = 0.11 0.11=1.1 * 2-1 (normalized a binary number)
Floating point Conversion Example (cont…) 1.1 * 2-1 (normalized a binary number) hidden The mantissa is positive so the sign S is given by: The biased exponent E is given by E = e + 127 E = -1 + 127 = 12610 = Fractional part of mantissa M: M = (in 23 bits) The IEEE 754 single precision representation is given by: S = 0 011111102 .10000000000000000000000 0 01111110 10000000000000000000000 S E M 1 bits 8 bits 23 bits
Simplified Floating Point Multiplication Flowchart
Floating Point Multiplication Example Multiply the following two numbers represented in the IEEE 754 single precision format: X = -1810 represented as: and Y = 9.510 represented as: 1 10000011 00100000000000000000000 0 100000100 00110000000000000000000 (1) Value of one or both operands = 0? No, continue with step 2 (2) Compute the sign: S = Xs XOR Ys = 1 XOR 0 = 1 (3) Multiply the mantissas: The product of the 24 bit mantissas is 48 bits with two bits to the left of the binary point: (01).0101011000000….000000 Truncate to 24 bits: hidden ® (1).01010110000000000000000 (4) Compute exponent of result: Xe + Ye - 12710 = 1000 0011 + 1000 0010 - 0111111 = 1000 0110 (5) Result mantissa needs normalization? No (6) Overflow? No. Underflow? No Result 1 10000110 01010101100000000000000
IEEE 754 Single precision Multiplication Rounding terjadi dalam floating point multiplication saat mantissa berubah dari 48bit jadi 24 bit. Overflow Overflow terjadi ketika jumlah exponents lebih dari 127 Saat ini exponent mulai dari 128 ( E=225 ) dan mantissa di set = 0 Overflow terjadi saat hasil tidak memiliki tanda sesuai dengan tanda operand ( hasil negatif akan didapatkan saat menambah2 angka positif ) Digunakan two’s complement untuk adding or subtracting numbers A carry occurs when the result of an addition or subtraction, considering the operands and result as unsigned numbers, does not fit in the result.
IEEE 754 Single precision Multiplication Underflow Underflow terjadi saat penjumlahan dari exponent lebih dari (-)126, angka negatif yang di definisikan dalam bias adalah (-)127 Angka yang bukan nol adalah 2 – 149, untuk mempertahankan ketepatan tiap 1 bit dalam mantissa. Saat ini, exponent di set (-)127 (E=0) -If M = 0, the number is exactly zero. -If M is not zero, then a denormalized number is indicated which has an exponent of -127 and a hidden bit of 0.
IEEE 754 Single precision Multiplication Underflow Arithmetic underflow (or "floating point underflow", "floating underflow", "underflow") adalah kondisi dimana hasil dari floating point operation lebih kecil dalam (mendekati nol, angka positif/negatif) Contoh : For example, an eight-bit two's complement exponent can represent multipliers of 2 - 128 to 2127. A result less than 2 - 128 would cause underflow.