THE IEEE STANDARD FOR FLOATING-POINT (IEEE 754) A technical standard for floatin
ID: 3725406 • Letter: T
Question
THE IEEE STANDARD FOR FLOATING-POINT (IEEE 754) A technical standard for floating-point computation established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE) The standard addressed many problems found in the diverse floating-point implementations that made them difficult to use reliably and portably Many hardware floating-point units now use the IEEE 754 standard PHASE #1-Description: Develop a plan to design and finally implement a set of functions using C++ that would implement the IEEE standard. Phase 1 will include the literature write up, description of the IEEE 754 (single, double) and a complete description of the functions implemented inctuding 1. Functions type void, or any data returning function 2. Type of data passed in to the functions (function parameters or arguments) 3. Type of function parameters (value or reference). 4. Global variables if needed 5· IEEE 754 single precision layout and its individual parts (sign, exponent, and mantissa) details. 6. IEEE 754 double precision layout and its individual parts (sign, exponent, and mantissa) details 7· The hexadecimal layout of both precision. 8. Work out a full example from A to Z SUGGESTED FUNCTIONS PLAN: MENU To display the user options... SPLITTER To split the mmber to whole and fraction. .etc WHOLECONVERTER Whole Part binary coverter.. etc FRACTIONCONVERTER
Explanation / Answer
code:
#include <limits.h>
#include <io stream>
3include <math.h>
#include <bitset>
int Binary 2 Hex ( std :: string Binary)
{
std:: bitset <32> set(Binary);
int hex = set.to_ulong();
return hex;
}
float getfloat 32(std::string Binary)
{
int HexNumber = Binary2 Hex (Binary);
bool negative == ( HexNumber & 0x80000000);
int exponet = (Hexnumber & 0x7f800000)>> 23;
int sign = negative ? -1:1;
exponent = -127;
total += 1.0;
float value = sign (float)pow(2.0, exponent)* total;
return value;
}
std :: string GetBinary 32(floatvalue)
{
union
{
float input;
int output;
)
data;
data.input = value ;
}
int main ()
{
std :: string str = GetBinary32 (float ) 19.5;
std :: cout << Binary Equivalent of 19.5 ;" << std :: endl;
std :: cout << str << st:: endl<< std:: endl;
float f = Get float 32(str);
std :: cout << " decimal equivalent of " << str<< " : " << std :: endl;
std :: cout << f << std :: endl;
return0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.