SlideShare a Scribd company logo
1 of 2
Download to read offline
II Floating Point Representation Using Strings Understanding how floating point numbers are
represented in memory, and how to manipulate that representation, is crucial to having a clear
view of how computer systems work and to writing efficient software. In this exercise, our goal
is to understand the floating point representation and how it is interpreted. We will convert a
simple floating number to its binary representation in the form of a string, then we will construct
our own representation to consolidate our understanding of the different components that make
up a float. 1. Given a floating point number as input: (a) Write a function that converts this
number to a string. This string is the binary representation of the floating point number. (b) Write
a function that takes the previously created string and switches the positions of the exponent and
the significand. The function returns the newly created string as output. Example: Given the
203.5 float as input: 1 (a) Converting the float to the string binary representation results in the
following string 01000011010010111000000000000000 The sign bit is highlighted in orange,
the exponent is highlighted in red, and the significand is highlighted in green. (b) In the string
representation we got previously, switching the exponent and significant results in the following
string 01001011100000000000000010000110 2. Transform the result of the previous question
from 32 bits to 64 bits (double-precision floatingpoint format). The function takes as input the 32
-bit string representation of a float and returns a string containing the 64-bit representation. In
order to obtain the 64-bit representation, you need to expand the exponent (from 8 bits to 11) and
significand (from 23 to 52 ). Example: (a) Starting from the string obtained in the question
(II.1.b): 01001011100000000000000010000110 (b) Expand the exponent (from 8 bits to 11) and
significand (from 23 to 52):
0100101110000000000000000000000000000000000000000000010000000110 III Floating
Point Representation Using Bit Manipulation Manipulating floats through their string
representation is not efficient or practical. In real-world applications, one would modify the
representation of floats using bit manipulation. Bit manipulation is useful beyond the scope of
modifying floating points. It's a powerful tool used in many applications, such as data
encryption, compression, image processing, and set manipulation. We want to perform the
previous steps using bit manipulation instead of string manipulation. Given a float as input, write
the following functions: 1. A function that prints the binary representation of an unsigned
integer. It takes an unsigned integer as input and prints its bits to the console standard output.
This is a helper function that should help you print the different intermediate values and check
your work. You can also use it to print the binary representation of a float by casting 1 that float
into an unsigned integer and then calling this function. Example: (a) Given the 203.5 float as
input (use casting to pass it to the function). (b) The function prints:
01000011010010111000000000000000 2. A function that extracts the significand from the input
float using bit manipulation. The function takes a float as input and returns an unsigned int
containing the significand. Example: (a) Given the 203.5 float as input. (b) The function returns
an unsigned integer that has the following binary representation:
00000000010010111000000000000000 3. Use the previous function to extract the significand of
the input into an integer and print it. Example: 1 Casting should be done at the pointer level. 2 (a)
Using the previous example (2.b), Printing the significand as an integer returns: 4947968 4. A
function that extracts the exponent from the input float using bit manipulation. The function
takes a float as input and returns an unsigned int containing the exponent. Example: (a) Given
the 203.5 float as input. (b) After using the function to extract the exponent, the print function
would return the following: 0100001100000000000000000000000 5. A function that extracts the
sign bit from the input float using bit manipulation. The function takes a float as input and
returns an unsigned int containing the sign bit. Example: (a) Given the 203.5 float as input. (b)
After using the function to extract the sign, the print function would print the following:
00000000000000000000000000000000 6. A function that switches the significand and exponent
positions in float using bit operations. The function makes use of the previously developed code
and takes as input a float, and returns an unsigned integer containing the new representation.
Example: (a) Given the 203.5 float as input. (b) Running the input into the function and then
printing the results with the print function returns: 01001011100000000000000010000110 (c)
Printing the newly switched number as a float shows: 16777484.000000

More Related Content

Similar to II Floating Point Representation Using Strings Understanding how float.pdf

GSP 215 Effective Communication - tutorialrank.com
GSP 215  Effective Communication - tutorialrank.comGSP 215  Effective Communication - tutorialrank.com
GSP 215 Effective Communication - tutorialrank.comBartholomew35
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comamaranthbeg8
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.combellflower126
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.combellflower148
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.combellflower169
 
C bitwise operators
C bitwise operatorsC bitwise operators
C bitwise operatorsSuneel Dogra
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comrobertleew18
 
Cse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionCse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionFarshidKhan
 
Write a function prototype for each of the following functions (Jus.pdf
Write a function prototype for each of the following functions (Jus.pdfWrite a function prototype for each of the following functions (Jus.pdf
Write a function prototype for each of the following functions (Jus.pdffashionfolionr
 
GSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comGSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comsholingarjosh136
 
Gsp 215 Massive Success / snaptutorial.com
Gsp 215  Massive Success / snaptutorial.comGsp 215  Massive Success / snaptutorial.com
Gsp 215 Massive Success / snaptutorial.comNorrisMistryzo
 
Gsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comGsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comStephenson101
 
Module_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptxModule_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptxrealme6igamerr
 
GSP 215 Education Organization - snaptutorial.com
GSP 215  Education Organization - snaptutorial.comGSP 215  Education Organization - snaptutorial.com
GSP 215 Education Organization - snaptutorial.comdonaldzs192
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.comStokesCope20
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.comHarrisGeorg21
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressionsStoian Kirov
 

Similar to II Floating Point Representation Using Strings Understanding how float.pdf (20)

GSP 215 Effective Communication - tutorialrank.com
GSP 215  Effective Communication - tutorialrank.comGSP 215  Effective Communication - tutorialrank.com
GSP 215 Effective Communication - tutorialrank.com
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
C bitwise operators
C bitwise operatorsC bitwise operators
C bitwise operators
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.com
 
Cse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionCse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expression
 
Write a function prototype for each of the following functions (Jus.pdf
Write a function prototype for each of the following functions (Jus.pdfWrite a function prototype for each of the following functions (Jus.pdf
Write a function prototype for each of the following functions (Jus.pdf
 
GSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comGSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.com
 
Gsp 215 Massive Success / snaptutorial.com
Gsp 215  Massive Success / snaptutorial.comGsp 215  Massive Success / snaptutorial.com
Gsp 215 Massive Success / snaptutorial.com
 
Gsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comGsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.com
 
Module_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptxModule_2_dspgggffffggggggggggggggga.pptx
Module_2_dspgggffffggggggggggggggga.pptx
 
GSP 215 Education Organization - snaptutorial.com
GSP 215  Education Organization - snaptutorial.comGSP 215  Education Organization - snaptutorial.com
GSP 215 Education Organization - snaptutorial.com
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.com
 
Computer Programming- Lecture 3
Computer Programming- Lecture 3Computer Programming- Lecture 3
Computer Programming- Lecture 3
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
 
python-ch2.pptx
python-ch2.pptxpython-ch2.pptx
python-ch2.pptx
 

More from asarudheen07

In a study of the incidence of Ebola virus- 1000 subjects were followe.pdf
In a study of the incidence of Ebola virus- 1000 subjects were followe.pdfIn a study of the incidence of Ebola virus- 1000 subjects were followe.pdf
In a study of the incidence of Ebola virus- 1000 subjects were followe.pdfasarudheen07
 
In a society of population N- the probability is p that a person has a.pdf
In a society of population N- the probability is p that a person has a.pdfIn a society of population N- the probability is p that a person has a.pdf
In a society of population N- the probability is p that a person has a.pdfasarudheen07
 
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdf
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdfIn a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdf
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdfasarudheen07
 
In a population where the effective population size (Ne) is 50 - allel.pdf
In a population where the effective population size (Ne) is 50 - allel.pdfIn a population where the effective population size (Ne) is 50 - allel.pdf
In a population where the effective population size (Ne) is 50 - allel.pdfasarudheen07
 
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdf
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdfIn a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdf
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdfasarudheen07
 
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdf
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdfIn a diploid plant species- gene R (with alleles R and r ) and gene F.pdf
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdfasarudheen07
 
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdf
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdfIn a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdf
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdfasarudheen07
 
In a paternity case- a mother- Jenny- claimed that the father of her c.pdf
In a paternity case- a mother- Jenny- claimed that the father of her c.pdfIn a paternity case- a mother- Jenny- claimed that the father of her c.pdf
In a paternity case- a mother- Jenny- claimed that the father of her c.pdfasarudheen07
 
In 2011 the Ministry of the environment reduced the acceptble concentr.pdf
In 2011 the Ministry of the environment reduced the acceptble concentr.pdfIn 2011 the Ministry of the environment reduced the acceptble concentr.pdf
In 2011 the Ministry of the environment reduced the acceptble concentr.pdfasarudheen07
 
In a follow up study- you decide to test whether the prevalence of WNV.pdf
In a follow up study- you decide to test whether the prevalence of WNV.pdfIn a follow up study- you decide to test whether the prevalence of WNV.pdf
In a follow up study- you decide to test whether the prevalence of WNV.pdfasarudheen07
 
In a digital age where computers are connected via network and data ar.pdf
In a digital age where computers are connected via network and data ar.pdfIn a digital age where computers are connected via network and data ar.pdf
In a digital age where computers are connected via network and data ar.pdfasarudheen07
 
In a certain city- the daly consumplion of water (in milions or bters).pdf
In a certain city- the daly consumplion of water (in milions or bters).pdfIn a certain city- the daly consumplion of water (in milions or bters).pdf
In a certain city- the daly consumplion of water (in milions or bters).pdfasarudheen07
 
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdf
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdfIn a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdf
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdfasarudheen07
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdf
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdfIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdf
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdfasarudheen07
 
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdf
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdfIn a 12-year grassland biodiversity experiment- 168 plots containing 1.pdf
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdfasarudheen07
 
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdfIn 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdfasarudheen07
 
In 2022- Juanita is married and files a joint tax return with her husb.pdf
In 2022- Juanita is married and files a joint tax return with her husb.pdfIn 2022- Juanita is married and files a joint tax return with her husb.pdf
In 2022- Juanita is married and files a joint tax return with her husb.pdfasarudheen07
 
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdf
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdfIn 2021- El Salvador became the first in the world to adopt bitcoin as.pdf
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdfasarudheen07
 
In 2018- which of the following is true about medical schools in the U.pdf
In 2018- which of the following is true about medical schools in the U.pdfIn 2018- which of the following is true about medical schools in the U.pdf
In 2018- which of the following is true about medical schools in the U.pdfasarudheen07
 
In 2013- the housing market started picking up- Were people getting th.pdf
In 2013- the housing market started picking up- Were people getting th.pdfIn 2013- the housing market started picking up- Were people getting th.pdf
In 2013- the housing market started picking up- Were people getting th.pdfasarudheen07
 

More from asarudheen07 (20)

In a study of the incidence of Ebola virus- 1000 subjects were followe.pdf
In a study of the incidence of Ebola virus- 1000 subjects were followe.pdfIn a study of the incidence of Ebola virus- 1000 subjects were followe.pdf
In a study of the incidence of Ebola virus- 1000 subjects were followe.pdf
 
In a society of population N- the probability is p that a person has a.pdf
In a society of population N- the probability is p that a person has a.pdfIn a society of population N- the probability is p that a person has a.pdf
In a society of population N- the probability is p that a person has a.pdf
 
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdf
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdfIn a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdf
In a eukaryotic cell- mature mRNA contains Multiple Choice a poly A ta.pdf
 
In a population where the effective population size (Ne) is 50 - allel.pdf
In a population where the effective population size (Ne) is 50 - allel.pdfIn a population where the effective population size (Ne) is 50 - allel.pdf
In a population where the effective population size (Ne) is 50 - allel.pdf
 
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdf
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdfIn a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdf
In a prokaryotic cell- how would the mRNA be different from a tRNA- 1-.pdf
 
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdf
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdfIn a diploid plant species- gene R (with alleles R and r ) and gene F.pdf
In a diploid plant species- gene R (with alleles R and r ) and gene F.pdf
 
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdf
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdfIn a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdf
In a new TCP connection that uses Selective Acknowledgment- If -0-125-.pdf
 
In a paternity case- a mother- Jenny- claimed that the father of her c.pdf
In a paternity case- a mother- Jenny- claimed that the father of her c.pdfIn a paternity case- a mother- Jenny- claimed that the father of her c.pdf
In a paternity case- a mother- Jenny- claimed that the father of her c.pdf
 
In 2011 the Ministry of the environment reduced the acceptble concentr.pdf
In 2011 the Ministry of the environment reduced the acceptble concentr.pdfIn 2011 the Ministry of the environment reduced the acceptble concentr.pdf
In 2011 the Ministry of the environment reduced the acceptble concentr.pdf
 
In a follow up study- you decide to test whether the prevalence of WNV.pdf
In a follow up study- you decide to test whether the prevalence of WNV.pdfIn a follow up study- you decide to test whether the prevalence of WNV.pdf
In a follow up study- you decide to test whether the prevalence of WNV.pdf
 
In a digital age where computers are connected via network and data ar.pdf
In a digital age where computers are connected via network and data ar.pdfIn a digital age where computers are connected via network and data ar.pdf
In a digital age where computers are connected via network and data ar.pdf
 
In a certain city- the daly consumplion of water (in milions or bters).pdf
In a certain city- the daly consumplion of water (in milions or bters).pdfIn a certain city- the daly consumplion of water (in milions or bters).pdf
In a certain city- the daly consumplion of water (in milions or bters).pdf
 
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdf
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdfIn a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdf
In a city- 70- of the people prefer Candidate A- Suppose 30 people fro.pdf
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdf
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdfIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdf
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.pdf
 
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdf
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdfIn a 12-year grassland biodiversity experiment- 168 plots containing 1.pdf
In a 12-year grassland biodiversity experiment- 168 plots containing 1.pdf
 
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdfIn 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $311-4 (1).pdf
 
In 2022- Juanita is married and files a joint tax return with her husb.pdf
In 2022- Juanita is married and files a joint tax return with her husb.pdfIn 2022- Juanita is married and files a joint tax return with her husb.pdf
In 2022- Juanita is married and files a joint tax return with her husb.pdf
 
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdf
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdfIn 2021- El Salvador became the first in the world to adopt bitcoin as.pdf
In 2021- El Salvador became the first in the world to adopt bitcoin as.pdf
 
In 2018- which of the following is true about medical schools in the U.pdf
In 2018- which of the following is true about medical schools in the U.pdfIn 2018- which of the following is true about medical schools in the U.pdf
In 2018- which of the following is true about medical schools in the U.pdf
 
In 2013- the housing market started picking up- Were people getting th.pdf
In 2013- the housing market started picking up- Were people getting th.pdfIn 2013- the housing market started picking up- Were people getting th.pdf
In 2013- the housing market started picking up- Were people getting th.pdf
 

Recently uploaded

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Recently uploaded (20)

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

II Floating Point Representation Using Strings Understanding how float.pdf

  • 1. II Floating Point Representation Using Strings Understanding how floating point numbers are represented in memory, and how to manipulate that representation, is crucial to having a clear view of how computer systems work and to writing efficient software. In this exercise, our goal is to understand the floating point representation and how it is interpreted. We will convert a simple floating number to its binary representation in the form of a string, then we will construct our own representation to consolidate our understanding of the different components that make up a float. 1. Given a floating point number as input: (a) Write a function that converts this number to a string. This string is the binary representation of the floating point number. (b) Write a function that takes the previously created string and switches the positions of the exponent and the significand. The function returns the newly created string as output. Example: Given the 203.5 float as input: 1 (a) Converting the float to the string binary representation results in the following string 01000011010010111000000000000000 The sign bit is highlighted in orange, the exponent is highlighted in red, and the significand is highlighted in green. (b) In the string representation we got previously, switching the exponent and significant results in the following string 01001011100000000000000010000110 2. Transform the result of the previous question from 32 bits to 64 bits (double-precision floatingpoint format). The function takes as input the 32 -bit string representation of a float and returns a string containing the 64-bit representation. In order to obtain the 64-bit representation, you need to expand the exponent (from 8 bits to 11) and significand (from 23 to 52 ). Example: (a) Starting from the string obtained in the question (II.1.b): 01001011100000000000000010000110 (b) Expand the exponent (from 8 bits to 11) and significand (from 23 to 52): 0100101110000000000000000000000000000000000000000000010000000110 III Floating Point Representation Using Bit Manipulation Manipulating floats through their string representation is not efficient or practical. In real-world applications, one would modify the representation of floats using bit manipulation. Bit manipulation is useful beyond the scope of modifying floating points. It's a powerful tool used in many applications, such as data encryption, compression, image processing, and set manipulation. We want to perform the previous steps using bit manipulation instead of string manipulation. Given a float as input, write the following functions: 1. A function that prints the binary representation of an unsigned integer. It takes an unsigned integer as input and prints its bits to the console standard output. This is a helper function that should help you print the different intermediate values and check your work. You can also use it to print the binary representation of a float by casting 1 that float into an unsigned integer and then calling this function. Example: (a) Given the 203.5 float as input (use casting to pass it to the function). (b) The function prints: 01000011010010111000000000000000 2. A function that extracts the significand from the input float using bit manipulation. The function takes a float as input and returns an unsigned int containing the significand. Example: (a) Given the 203.5 float as input. (b) The function returns an unsigned integer that has the following binary representation: 00000000010010111000000000000000 3. Use the previous function to extract the significand of the input into an integer and print it. Example: 1 Casting should be done at the pointer level. 2 (a) Using the previous example (2.b), Printing the significand as an integer returns: 4947968 4. A function that extracts the exponent from the input float using bit manipulation. The function takes a float as input and returns an unsigned int containing the exponent. Example: (a) Given the 203.5 float as input. (b) After using the function to extract the exponent, the print function would return the following: 0100001100000000000000000000000 5. A function that extracts the sign bit from the input float using bit manipulation. The function takes a float as input and
  • 2. returns an unsigned int containing the sign bit. Example: (a) Given the 203.5 float as input. (b) After using the function to extract the sign, the print function would print the following: 00000000000000000000000000000000 6. A function that switches the significand and exponent positions in float using bit operations. The function makes use of the previously developed code and takes as input a float, and returns an unsigned integer containing the new representation. Example: (a) Given the 203.5 float as input. (b) Running the input into the function and then printing the results with the print function returns: 01001011100000000000000010000110 (c) Printing the newly switched number as a float shows: 16777484.000000