With <math.h>
included, round
is a standard C rounds its argument to the nearest integer, rounding halfway cases away from zero, and returning a double
.
Technically, round
is a function designator: It denotes the function. (round)
is merely the designator in parentheses. Like other parenthesized expressions, its type and value are the same as the expression inside it. So, functionally, (round)
is the same as round
, and (round)(3.14*2 / 1.618)
is the same round(3.14*2 / 1.618)
One difference is that <math.h>
may implement round
as a function-like macro. In this case, in round(x)
, the macro is expanded, and the resulting expression may be something other than a function call, or it could call a function with a different name. (The C standard requires the result to be the same as if the round
function had been called.) In (round)(x)
, the macro name round
is not immediately followed by a left parentheses, so the expansion of the function-like macro does not occur. Thus (round)(x)
calls the actual function even if a function-like macro is defined.
This behavior regarding putting function names in parentheses to suppress macro expansion is a deliberate feature of the C library (C 2018 7.1.4 1: “… Any macro definition of a function can be suppressed locally by enclosing the name of the function in parentheses,…”). However, there is no apparent reason to use it in this code.