1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Margaret [11]
2 years ago
10

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 floating and a complete description of the functions plan:
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. The hexadecimal layout.
7. Hand work out a full example from A to Z.

Computers and Technology
1 answer:
AnnZ [28]2 years ago
6 0

Answer:

See explaination code

Explanation:

#include<iostream>

#include<math.h>

using namespace std;

typedef union {

float number;

struct

{

// Order is important.

// Here the members of the union data structure

// use the same memory (32 bits).

// The ordering is taken

// from the LSB to the MSB.

unsigned int mantissa : 23;

unsigned int exponent : 8;

unsigned int sign : 1;

} Raw;

} MyFloat;

void printBinary(int n, int i)

{

// Prints the binary representation

// of a number n up to i-bits.

int k;

for (k = i - 1; k >= 0; k--) {

if ((n >> k) & 1)

cout << "1";

else

cout << "0";

}

}

void decToHex(int n){

// char array to store hexadecimal number

char hexaDeciNum[100];

// counter for hexadecimal number array

int i = 0;

while(n!=0)

{

// temporary variable to store remainder

int temp = 0;

// storing remainder in temp variable.

temp = n % 16;

// check if temp < 10

if(temp < 10)

{

hexaDeciNum[i] = temp + 48;

i++;

}

else

{

hexaDeciNum[i] = temp + 55;

i++;

}

n = n/16;

}

// printing hexadecimal number array in reverse order

for(int j=i-1; j>=0; j--)

cout << hexaDeciNum[j];

}

void floatBinary(float f){

long double binaryTotal, binaryFrac = 0.0, frac, fracFractor = 0.1;

long int integer, binaryInt = 0;

long int p = 0, rem, temp;

//separate the integer part from the input floating number

integer = (int)f;

//separate the fractional part from the input floating number

frac = f - integer;

//loop to convert integer part to binary

while (integer != 0) {

rem = integer % 2;

binaryInt = binaryInt + rem *pow(10, p);

integer = integer / 2;

p++;

}

//loop to convert fractional part to binary

while (frac != 0) {

frac = frac * 2;

temp = frac;

binaryFrac = binaryFrac + fracFractor * temp;

if (temp == 1)

frac = frac - temp;

fracFractor = fracFractor / 10;

}

cout << binaryInt + binaryFrac;

}

int findDecimal(float number){

int nfloor = number;

float nfloat = number - nfloor;

int nfloatfloor;

do {

nfloat *= 10;

nfloatfloor = nfloat;

} while (nfloat > nfloatfloor);

return nfloatfloor;

}

void first(float number){

if(number < 0)

cout << "SIGN BIT IS (1) SINCE NUMBER IS NEGATIVE" << endl;

else

cout << "SIGN BIT IS (0) SINCE NUMBER IS POSITIVE" << endl;

}

void second(float number){

cout << "INTEGER PART IN BASE-10:" << int(number) << " AND IN BINARY:";

printBinary(int(number),16);

cout << endl;

}

void third(float number){

cout << "DECIMAL PART IN BASE-10:" << findDecimal(number) << " AND IN BINARY:";

printBinary(findDecimal(number),16);

cout << endl;

}

void fourth(float number){

cout << "ENTERED NUMBER IN BASE-10:" << number << " AND IN BINARY:";

floatBinary(number);

cout << endl;

}

void fifth(MyFloat myfloat){

cout << "MANTISA IN BINARY:";

printBinary(myfloat.Raw.mantissa,32);

}

void sixth(MyFloat myfloat){

cout << "EXPONENT IN BASE-10:" << myfloat.Raw.exponent << " AND IN BINARY:";

printBinary(myfloat.Raw.exponent,8);

cout << endl;

}

void seventh(MyFloat myfloat){

cout << myfloat.Raw.sign << " | ";

printBinary(myfloat.Raw.exponent,8);

cout << " | ";

printBinary(myfloat.Raw.mantissa,32);

cout << endl;

}

void eigth(MyFloat myfloat){

cout << myfloat.Raw.sign << " | ";

decToHex(myfloat.Raw.exponent);

cout << " | ";

decToHex(myfloat.Raw.mantissa);

cout << endl;

}

int main(){

float number;

cout << "PLEASE ENTER A NUMBER TO DISPLAY THE IEEE 754 FLOATING POINT OPTIONS" << endl;

cin >> number;

MyFloat myfloat;

myfloat.number = number;

cout << "PLEASE CHOOSE ONE OF THE FOLLOWING OPERATIONS" << endl;

cout << " 1. DISPLAY THE SIGN BIT VALUE" << endl;

cout << " 2. DISPLAY THE INTEER PART IN BOTH BASE-10 AND CINARY FORMATS" << endl;

cout << " 3. DISPLAY THE DECIMAL PART IN BOTH BASE-10 AND BINARY FORMATS" << endl;

cout << " 4. DISPLAY THE NUMBER ENTERED IN BOTH BASE-10 AND BINARY FORMATS" << endl;

cout << " 5. DISPLAY THE MANTISA IN BINARY FORMATS" << endl;

cout << " 6. DISPLAY THE EXPONENT IN BORH BASEE-10 AND BINARY FORMATS" << endl;

cout << " 7. DISPLAY THE IEEE 754 SINGLE PRECISION BINARY LAYOUT" << endl;

cout << " 8. DISPLAY THE IEEE 754 SINGLE PRECISION BINARY LAYOUT" << endl;

int choice;

cin >> choice;

switch(choice){

case 1:first(number);

break;

case 2:second(number);

break;

case 3:third(number);

break;

case 4:fourth(number);

break;

case 5:fifth(myfloat);

break;

case 6:sixth(myfloat);

break;

case 7:seventh(myfloat);

break;

case 8:eigth(myfloat);

break;

default:cout << "ENTER VALID CHOICE" << endl;

}

}

Refer to attachment please for onscreen look.

You might be interested in
Which statement is true about biometrics as an authentication method?​
Irina-Kira [14]

The statement is true about biometrics as an authentication method in options b and c.

<h3>What is Biometrics?</h3>

Biometrics is the measurement worried in measuring behavior or physiological traits of the human being. It is used for verifying the identification of a specific man or woman. It is probably operated in modes, particularly authentication and enrollment.

The complete question is :

Which of the following are true in biometric systems?

  1. a. For authentication application, a user template is compared against a single template stored in the database.
  2. b. For verification/identification application, a user template is compared against all the templates stored in the database.
  3. c. Multimodal biometrics is used to improve accuracy.
  4. d. None of these.

In the first mode, the facts is used and proven to test who the man or woman is. The second mode is obtaining the man or woman's facts and storing it in a database. Usually, multi-version biometrics are used for enhancing popularity accuracy.

Read more about the authentication :

brainly.com/question/25689052

#SPJ1

3 0
2 years ago
Charlie does not think he will be able to finish his project by the deadline at this point in the decision making progress to so
NemiM [27]
A and B are out because Charlie knows his problem is he is not going to finish in time. D is out because he hasn't talked to his manager yet. so only choice left is C. decide if he should talk to his manager about the problem he now knows
5 0
3 years ago
In today's society, unethical actions are: A) Easier than ever to get away with, because the general public and insurers are les
ra1l [238]
B I think is the best answer
7 0
3 years ago
Read 2 more answers
Which of the following can a cell contain?
Ksju [112]
The answer is choice D-All of these :)
8 0
3 years ago
Read 2 more answers
What kind of eolr would you need to not have a open trouble on the facp
zhannawk [14.2K]

Answer:

here are three basic categories for fire alarm panel signals: trouble, supervisory, and alarm. Trouble Signal. A trouble signal is typically designated by a yellow light and means that there is an operational issue. For some more advanced systems, the panel may indicate the kind of problem and where it is located.

Explanation:

8 0
3 years ago
Other questions:
  • if the president goes for vice president after his 2 term and the present president dies is the old president the president agai
    8·2 answers
  • Think about the five steps to writing an algorithm. Why is each step necessary? Why is it important to be precise when writing c
    15·1 answer
  • Write a method that take an integer array as a parameter and returns the sum of positive odd numbers and sum of positive even nu
    13·1 answer
  • Program should allow for user to enter students name and his four test scores it should calculate and display the average and le
    7·1 answer
  • Which attribute of the image tag specifies the URL of an image
    14·1 answer
  • Explain how computer system is different from computer in 150 words
    14·1 answer
  • PLEASE HELP!!!!!!!!!
    8·1 answer
  • How dose society use computer in government?​
    5·1 answer
  • What will the following code display? int numbers[4] = { 99, 87 }; cout &lt;&lt; numbers[3] &lt;&lt; endl; a. 87 b.0 d. 34. What
    12·1 answer
  • Whats the flow in this code, and whats the risk that its creating and what can i do to fix it? (c language)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!