Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Introduction of Floating Point Representation
Next article icon

Introduction of Floating Point Representation

Last Updated : 17 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

1. To convert the floating point into decimal, we have 3 elements in a 32-bit floating point representation: 
    i) Sign 
    ii) Exponent 
    iii) Mantissa 


 

  • Sign bit is the first bit of the binary representation. '1' implies negative number and '0' implies positive number. 
    Example: 11000001110100000000000000000000 This is negative number.
  • Exponent is decided by the next 8 bits of binary representation. 127 is the unique number for 32 bit floating point representation. It is known as bias. It is determined by 2k-1 -1 where 'k' is the number of bits in exponent field. 

    There are 3 exponent bits in 8-bit representation and 8 exponent bits in 32-bit representation.

    Thus

    bias = 3 for 8 bit conversion (23-1 -1 = 4-1 = 3) 
    bias = 127 for 32 bit conversion. (28-1 -1 = 128-1 = 127) 

    Example: 01000001110100000000000000000000 
    10000011 = (131)10 
    131-127 = 4 

    Hence the exponent of 2 will be 4 i.e. 24 = 16.
  • Mantissa is calculated from the remaining 23 bits of the binary representation. It consists of '1' and a fractional part which is determined by: 

    Example: 

    01000001110100000000000000000000 

    The fractional part of mantissa is given by: 

    1*(1/2) + 0*(1/4) + 1*(1/8) + 0*(1/16) +......... = 0.625 

    Thus the mantissa will be 1 + 0.625 = 1.625 

    The decimal number hence given as: Sign*Exponent*Mantissa = (-1)0*(16)*(1.625) = 26





2. To convert the decimal into floating point, we have 3 elements in a 32-bit floating point representation: 
    i) Sign (MSB) 
    ii) Exponent (8 bits after MSB) 
    iii) Mantissa (Remaining 23 bits) 
 

  • Sign bit is the first bit of the binary representation. '1' implies negative number and '0' implies positive number. 
    Example: To convert -17 into 32-bit floating point representation Sign bit = 1
  • Exponent is decided by the nearest smaller or equal to 2n number. For 17, 16 is the nearest 2n. Hence the exponent of 2 will be 4 since 24 = 16. 127 is the unique number for 32 bit floating point representation. It is known as bias. It is determined by 2k-1 -1 where 'k' is the number of bits in exponent field. 

    Thus bias = 127 for 32 bit. (28-1 -1 = 128-1 = 127) 

    Now, 127 + 4 = 131 i.e. 10000011 in binary representation.
  • Mantissa: 17 in binary = 10001.


    Move the binary point so that there is only one bit from the left. Adjust the exponent of 2 so that the value does not change. This is normalizing the number. 1.0001 x 24. Now, consider the fractional part and represented as 23 bits by adding zeros.


    00010000000000000000000


 

Advantages:

Wide range of values: Floating factor illustration lets in for a extensive variety of values to be represented, along with very massive and really small numbers.

Precision: Floating factor illustration offers excessive precision, that is important for medical and engineering calculations.

Compatibility: Floating point illustration is extensively used in computer structures, making it well matched with a extensive variety of software and hardware.

Easy to use: Most programming languages offer integrated guide for floating factor illustration, making it smooth to use and control in laptop programs.

Disadvantages:

Complexity: Floating factor illustration is complex and can be tough to understand, mainly for folks that aren't acquainted with the underlying mathematics.

Rounding errors: Floating factor illustration can result in rounding mistakes, where the real price of a number of is barely extraordinary from its illustration inside the computer.

Speed: Floating factor operations can be slower than integer operations, particularly on older or much less powerful hardware.

Limited precision: Despite its excessive precision, floating factor representation has a restrained number of sizeable digits, which could restrict its usefulness in some programs.




Related Link: 
https://www.youtube.com/watch?v=03fhijH6e2w

More questions on number representation: 
https://www.geeksforgeeks.org/number-representation-gq/ 

This article is contributed by Kriti Kushwaha

 


 


Next Article
Introduction of Floating Point Representation

K

Kriti Kushwaha
Improve
Article Tags :
  • Digital Logic

Similar Reads

    Shift Registers in Digital Logic
    Pre-Requisite: Flip-FlopsFlip flops can be used to store a single bit of binary data (1 or 0). However, in order to store multiple bits of data, we need multiple flip-flops. N flip flops are to be connected in order to store n bits of data. A Register is a device that is used to store such informati
    8 min read
    Design 101 sequence detector (Mealy machine)
    A sequence detector is a sequential state machine that takes an input string of bits and generates an output 1 whenever the target sequence has been detected. In a Mealy machine, output depends on the present state and the external input (x). Hence, in the diagram, the output is written outside the
    5 min read
    Amortized analysis for increment in counter
    Amortized analysis refers to determining the time-averaged running time for a sequence (not an individual) operation. It is different from average case analysis because here, we don't assume that the data arranged in average (not very bad) fashion like we do for average case analysis for quick sort.
    4 min read
    Number System and Base Conversions
    Electronic and digital systems use various number systems such as Decimal, Binary, Hexadecimal and Octal, which are essential in computing. Binary (base-2) is the foundation of digital systems.Hexadecimal (base-16) and Octal (base-8) are commonly used to simplify the representation of binary data. T
    9 min read
    Code Converters - BCD(8421) to/from Excess-3
    Prerequisite - Number System and base conversions Excess-3 binary code is an unweighted self-complementary BCD code. Self-Complementary property means that the 1's complement of an excess-3 number is the excess-3 code of the 9's complement of the corresponding decimal number. This property is useful
    5 min read
    Code Converters - Binary to/from Gray Code
    In this article, we will go through Code Converters - Binary to/from Gray Code, we will start our article by defining Code converters, Binary code and Gray code, and then we will go through the conversion of binary code to gray code and vice versa.Table Of ContentCode ConvertersBinary CodeGray CodeC
    5 min read
    Program for Decimal to Binary Conversion
    Given a non negative number n, the task is to convert the given number into an equivalent binary representation.Examples: Input: n = 12Output: "1100"Explanation: the binary representation of 12 is "1100", since 12 = 1×23 + 1×22 + 0×21+ 0×20 = 12Input: n = 33Output: "100001"Explanation: the binary re
    10 min read
    Program for Binary To Decimal Conversion
    Given a binary number as input, we need to write a program to convert the given binary number into an equivalent decimal number.Examples : Input : 111Output : 7Explanation : The output of 7 for input 111 represents the decimal equivalent of the binary number 111.Input : 1010Output : 10Explanation :
    15 min read
    Program for Decimal to Octal Conversion
    Given a decimal number as input, we need to write a program to convert the given decimal number into an equivalent octal number. i.e convert the number with base value 10 to base value 8. The base value of a number system determines the number of digits used to represent a numeric value. For example
    10 min read
    Program for Octal to Decimal Conversion
    Given an octal number as input, we need to write a program to convert the given octal number into equivalent decimal number. Examples: Input : 67Output: 55Input : 512Output: 330Input : 123Output: 83The idea is to extract the digits of a given octal number starting from the rightmost digit and keep a
    11 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences