1. Implement the following rounding function that rounds a 64-bit floating point number (type double) to the nearest 32-bit integer (type int). You may assume that the type double complies with the IEEE standard 754. The function is only required to work correctly if the nearest integer is in the value range of the type int, otherwise, the return value of the function is undefined.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
3.
Task 3: Rounding
Open Task
Task
1. Implement the following rounding function that rounds a 64-bit floating point
number (type double) to the nearest 32-bit integer (type int). You may
assume that the type double complies with the IEEE standard 754. The
function is only required to work correctly if the nearest integer is in the value
range of the type int, otherwise, the return value of the function is
undefined.
Note: Usage of library rounding functions (standard or others) is not
allowed.
2 of 4
2019-10-15 10:45
Exercise 5: Floating Point Calculations & Basic...
https://expert.ethz.ch/print/ifme1/AS19/XgRNvf...
// PRE:
// POST: return value is the integer nearest to x, or the or
//
int round (double x);
x is roundable to a number in the value range of ty
away from 0 if x lies right in between two integers
2. Write a program which inputs a number of type double from the user, then
rounds this number using your function from (1), and then outputs the
rounded number.
Transcribed Image Text:Task 3: Rounding Open Task Task 1. Implement the following rounding function that rounds a 64-bit floating point number (type double) to the nearest 32-bit integer (type int). You may assume that the type double complies with the IEEE standard 754. The function is only required to work correctly if the nearest integer is in the value range of the type int, otherwise, the return value of the function is undefined. Note: Usage of library rounding functions (standard or others) is not allowed. 2 of 4 2019-10-15 10:45 Exercise 5: Floating Point Calculations & Basic... https://expert.ethz.ch/print/ifme1/AS19/XgRNvf... // PRE: // POST: return value is the integer nearest to x, or the or // int round (double x); x is roundable to a number in the value range of ty away from 0 if x lies right in between two integers 2. Write a program which inputs a number of type double from the user, then rounds this number using your function from (1), and then outputs the rounded number.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY