How To Set A Register To Contain Certain Bits Of An Integer In Mips?
Floating Indicate Representation
Numbers with fractions that can be put in the form,
can be represented as floating point numbers in computers.
These numbers are called floating points because the binary point is non fixed. Up until about 1980s unlike figurer manufacturers used different formats for representing floating indicate numbers, but with the introduction of IEEE standard 754, nowadays nearly all the computers follow the said standards which profoundly increased the portability of floating point data.
IEEE Floating Signal Representation
IEEE standard defines three formats for representing floating point numbers,
- Single Precision (32 bits)
- Double Precision (64 $.25)
- Extended Precision (80 bits)
and with this standard, floating point numbers are represented in the form,
s represents the sign of the number. When s=ane, floating point number is negative and when s=0 information technology is positive. F represent the fraction (which is also called mantissa) and E is the exponent.
Construction of the ii most usually used formats are shown below.
Single Precision (32-flake)
Double Precision (64-scrap)
Now let's see how we tin convert a given decimal number to a floating point binary representation. Lets take -4.40625 as an case.
Step 1:
First convert the integral part which is 4 to binary.
Step ii:
Then we can multiply the fractional part repeatedly past 2 and pick the bit that appears on the left of the decimal to go the binary representation of the fractional part. For example,
Pace 3:
Now nosotros need to normalize the number by moving the binary indicate so that it takes the form,
Ane very important affair to remember here is, that the leading ane bit does not need to be stored since information technology is unsaid. That is a clever fob used by the standard to get additional infinite for fractional part. So for the fractional part(23 or 52 bits) nosotros need just to salve 0001101 in this case and fill the rest of the its bits on to the right with 0s.
Step iv:
Now the exponent is represented as a integer in biased form. So if the exponent has k-$.25 then the bias equals to,
Add this bias to the exponent and place it in the exponent section. With single precision, k has 8 bits so the exponent value in this example equals to,
Finally the sign bit is set according to the original sign of the number. That is 1 for negative and 0 for positive.
So the decimal value -4.40625 in binary form tin can be represented equally,
Special Cases — Infinity and NaN
Infinity — When the exponent bits are all ones and the fraction bits are all 0 so the resulting value represents infinity.
NaN — When exponent bits are all ones simply the fraction value is not zero then the resulting value is said to be NaN which is short for Not a Number. You get this value when y'all perform invalid operations like dividing zero past cipher, subtracting infinity from infinity etc…
References
- http://sandbox.mc.edu/~bennet/cs110/flt/dtof.html
- https://www.amazon.de/Computer-Systems-Programmers-Perspective-Global/dp/1292101768
- https://world wide web.amazon.com/Computer-Organization-Design-MIPS-Fifth/dp/0124077269
- https://www.amazon.com/Structured-Figurer-Organization-Andrew-Tanenbaum/dp/0132916525
Source: https://medium.com/coderscorner/floating-point-representation-63114653c9ee
Posted by: steinvoiled.blogspot.com

0 Response to "How To Set A Register To Contain Certain Bits Of An Integer In Mips?"
Post a Comment