UNDERSTANDING THE IEEE 754 CONVERTER FORMAT

Table of Contents

Introduction

Computers operates on binary number system i.e. 1s and 0s, but it is not intuitive for humans who are accustomed to the decimal system. To bridge this gap, the IEEE 754 converter format hexadecimal number system is widely used in computing. IEEE 754 converter format hexadecimal numbers play a crucial role in low-level programming languages like Assembly, C, and C++, appearing frequently in memory addressing, bitwise operations, machine code representation, and debugging processes. Debuggers and error messages often display system information in IEEE 754 converter format, requiring programmers to be familiar with this notation to troubleshoot issues effectively. So mastering this number system is essential for anyone working in system-level programming, embedded systems, operating systems, or hardware design, allowing for efficient memory management, code optimization, and better interpretation of system diagnostics.

IEEE 754 converter Format

Number System :

Decimal Number:

If we look at decimal number system for example 5849.566, it is actually represent as \(5\times10^3 + 8\times10^2 + 4\times10^1 + 9\times10^0 + 5\times10^{-1} + 6\times10^{-2} + 6\times10^{-3} \).

Binary System :

In binary number system we use powers of 2 instead of 10 in decimal system. For example the binary value 10011011 represents \(1\times2^7 + 0\times2^6 + 0\times2^5 + 1\times2^4 + 1\times2^3 + 0\times2^2 + 1\times2^1 + 1\times2^0\).

Above example is a unsigned binary number , now we will see how to represent a signed binary number. Most popular method to represent signed and unsigned binary number is two’s compliment notation. in two’s compliment natation if H.O bit( higher order bit – the left most bit of a binary number) is 1 the number is negative and if H.O bit is 0 then number is positive. So H.O bit is called sign bit. For example 0000_1000 (8 in decimal ) if we want to make it -8 then we have to invert all the bits which is 1111_0111, then add 1 to it. 1111_0111 + 1 = 1111_1000(binary addition is 0+0=0, 1+0=1, 1+1=0(carry 1)) so 1111_1000 represent two’s compliment for -8. To convert -8 to 8 , apply two’s compliment on 1111_1000. Invert it to get 0000_0111 and add 1 to get 0000_1000 (8 in decimal).

Suppose we have -89 and we want to convert it into binary then convert the absolute value of decimal to binary which is 89 = 0101_1001, then apply two’s compliment to that binary, so invert it to get 1010_0110, then add 1 to get 1010_0111(-89).

How to represent floating point binary value? suppose we have 10110.11011 and we will convert it to decimal then \(1\times2^4 + 0\times2^3 + 1\times2^2 + ….. + 0\times2^{-3} + 1\times2^{-4} + 1\times2^{-5 }= 22.84375\). To convert vice versa first convert the integer part by dividing 2 and retain the remainder. We will get 10110, then for fractional part multiply 2 and retain the integer part until fractional part becomes 0. i.e. \(0.84375 \times 2 = 1.68750\), retain 1 from result and multiply again 2 with fractional part i.e. 0.68750, will get 1.375, retain 1, multiply 2 with fraction 0.375, will get 0.75, retain 0, multiply 2 with fraction part 0.75 will get 1.5 , retain 1 , multiply \(2 \times 0.5 = 1.0\) retain 1 , stop. So answer is 10110.11011.

Hexadecimal System:

It is very easy to convert hexadecimal number to binary and binary to hexadecimal, that is why it is widely used. as we know in binary system we have two digits(1 & 0) to work with and in decimal we have 0 to 9, like wise we have 16 numbers i.e. 0 to 15 to work with hexadecimal, but there is a twist, here we have 0 to 9 as single digits to represent but 10 to 15 are double digits. That’s why we have to represent 10 as A, 11 as B, 12 as C, 13 as D, 14 as E, 15 as F. In binary A to F have 4 bits so we have to represent 0 to F with 4 bits in binary form. Table is given below .

IEEE 754 format

Hexadecimal To Binary :

Hexadecimal to binary just put 4bits from table to there respective value , for example C4D5E is in hexadecimal to convert it to binary put respective values from table, 1100_0100_1101_0101_1110 .

Binary To Hexadecimal :

Binary to hexadecimal make it multiples of 4 bits by putting zeros in left side and put values from table , for example 10101000100101 , we have to make it multiples of 4 bits like this 10_1010_0010_0101 and put two zeros in left side to make it multiple of 4 bits 0010_1010_0010_0101, then put values from table i.e. 2A25.

Decimal To Hexadecimal :

Decimal to hexadecimal direct conversion is also easy , here you have to divide 16 from decimal digit and retain remainders as hexadecimal. For example 567 in decimal , to convert it to hexadecimal divide it with 16 and get 35 as quotient and remainder 7, again divide 35 with 16 will get 2 as quotient and 3 as remainder. So 237 is hexadecimal representation of 567 in decimal.

Hexadecimal To Decimal :

Take the above example 237 in hexadecimal , here we have to multiply powers of 16 instead of 10 like we did in decimal number system . \(2\times16^2 + 3\times16^1 + 7\times16^0 =512+48+7=567\).

IEEE 754 Converter Format Hexadecimal :

Suppose we have to convert decimal number 22.8437 to IEEE 754 converter format hexadecimal then, convert it to binary which is 1011.11011. Then normalize it to scientific notation i.e. \(1.xxxx \times 2^n\). So \(1011.11011 = 1.01111011 \times 2^3 \), 1.01111011 is called mantissa and 3(we put 3 because we have shifted decimal point 3 step left to get the format \(1.xxx \times 2^n\) ) is called exponent. It is a positive number so put sign bit 0. So in IEEE 754 converter format single precision ( 32 bit , which we use mostly in embedded system ,graphics, machine learning ) 1 bit for sign , 8 bits for exponent and remaining 23 bits for fraction part (remaining bits after 1.) of mantissa (significand). You must be wondering where will (1.) will store in 32bits IEEE 754 converter format single precision, 1. is not stored explicitly, since it present in normalized form no need to store it , it is just assumed that 1. is there including sign, mantissa and exponent. Another thing is we always use IEEE 754 converter format single precision (32 bit) we store the exponent part as per the formula “Stored exponent = Actual exponent + Bias”. In our example Actual exponent is 3, and bias is always 127 in 32bit IEEE 754 converter format floating point, so stored exponent will be \(127 + 3 =130\) , 130 converted to binary is 1000_0010, now put all these in 32bits, 0 1000_0010 01111011000000000000000 ( putting zeros in remaining right bits of 23 bits of mantissa ). Now to convert it to hexadecimal separate it to multiples of 4bit, so we get 0100_0001_0011_1101_1000_0000_0000_0000, now convert it to hexadecimal i.e 413D8000, now put 0x In front of it to indicate the number is in IEEE 754 converter format hexadecimal 0x413D8000.
Now we convert decimal -237  to IEEE 754 converter format single precision 32bit floating point format. Binary of 237 is 1110_1101, then normalize it \(1.1101101 \times 2^7\). Sign bit is 1 because decimal is negative. Stored exponent is 127 + 7 = 134, 134 converted to binary is 1000_0110, mantissa is 11011010000000000000000. Put all the digits in multiple of 4bits i.e. 1100_0011_0110_1101_0000_0000_0000_0000, now put hexadecimal values from the table with 0x in front of it, i.e. 0xC36D0000.

Conclusion:

So, that’s all!, we often encounter values like 0xC36D0000 (IEEE 754 converter format) in assembly language, C, and C++. Whether working with memory, pointers, addresses, or binary data, understanding the IEEE 754 converter format is crucial. It bridges the gap between human-readable numbers and how computers actually store and process them. Mastering this concept will make you a more efficient programmer, especially when dealing with hardware, floating-point arithmetic, and optimizations.
If you find it helpful please write to us, Thank you.

2 thoughts on “UNDERSTANDING THE IEEE 754 CONVERTER FORMAT”

  1. Pingback: Fundamentals of data types in C language

  2. Pingback: CPU registers : 8 Tiny Components, Massive Impact

Leave a Reply

Scroll to Top

Discover more from Orlyset

Subscribe now to keep reading and get access to the full archive.

Continue reading