In the function round of Display 3.6, which of these explains what happens in the body of the function? We reproduce the one line from the function body here:

```
return static_cast(floor(number+0.5));
```

a) This is overkill, it would be sufficient to use the floor function alone.
b) Adding 0.5 to number pushes the range up so floor can produce the correct rounding.
c) The static_cast is used because floor returns a double. If the double value were returned, there would be at least a warning of a double to int conversion in returning the value.
d) This is wrong. The argument for the floor function should be number-0.5.


b) Adding 0.5 to number pushes the range up so floor can produce the correct rounding., and c) The static_cast is used because floor returns a double. If the double value were returned, there would be at least a warning of a double to int conversion in returning the value.

Numbers between floor(number)+0.5 and floor(number)+1 should round to floor(number)+1. The expression number+0.5 pushes numbers in the range floor(number) and floor(number)+0.5 up so floor will produce the correct rounded number. It pushes numbers between floor(number) and floor(number)+0.5 to floor(number)+0.5 up but leaves them so that floor will produce the correct rounded value, namely floor(number).

Computer Science & Information Technology

You might also like to view...

Switches and ____ are the physical components that interconnect the computers within a network.

A. routers B. hubs C. firewalls D. proxies

Computer Science & Information Technology

A ________ is a pointing device that simulates using a pen on a tablet computer

A) mouse B) computer stick C) stylus D) digital writer

Computer Science & Information Technology

The methods for computing joins discussed in Section 10.5 all deal with equi-joins. Discuss their applicability to the problem of computing inequality joins, such as r daA

Suppose we use sort-merge join to compute inequality joins, such as r daA

Computer Science & Information Technology

? ? Referring to the figure above, "Vacation" is chosen by default by using the ____ attribute.

A. chosen B. checked C. marked D. button

Computer Science & Information Technology