The C standard library provides families of round , lround and llround in C99. However, these functions are not compatible with IEEE-754, because they do not implement "rounding of bankers" from half to parity, as provided by IEEE ...
It makes no sense to talk about whether an individual feature is "IEEE-754 compliant." Compliance with IEEE-754 requires a set of data type operations with specific semantics. It does not require that these types or operations have specific names, and it does not require that only those operations be available. An implementation can provide any additional features that it wants, and still be compatible. If an implementation wants to provide rounded, round-random, rounded-from-zero, and trap-if-inexact, it can do it.
In fact, rounding is required for the IQE-754, as there are six operations:
convertToIntegerTiesToEven (x)
convertToIntegerTowardZero (x)
convertToIntegerTowardPositive (x)
convertToIntegerTowardNegative (x)
convertToIntegerTiesToAway (x)
convertToIntegerExact (x)
In C and C ++, the last five of these operations are tied to the trunc , ceil , floor , round and rint , respectively. C11 and C ++ 14 do not have a binding for the first, but roundeven will be used in future versions. As you can see, round actually one of the necessary operations.
However, roundeven not available in current implementations, which brings us to the next part of your question:
The usual ad-hoc way to implement rounding in C is to use the expression (int)(x + 0.5f) , which, although it is incorrect in strict IEEE-754 math, is usually translated by the compilers into the correct cvtss2si instruction. However, this, of course, is not a figurative assumption.
The problems with this expression are far superior to "rigorous IEEE-754 math." This is absolutely wrong for negative x , gives the wrong answer for nextDown(0.5) and turns all the odd integers in bin ** 2 23 into even integers. Any compiler that translates it to cvtss2si is horribly, horribly broken. If you have an example of this event, I would really like to see it.
How can I implement a function that will span any floating point value with semi-parity semantics?
As noted in the njuffa comment, you can make sure the rounding mode is set to the default and use rint (or lrint , since it seems like you really want to get an integer result) or you can implement your own rounding function by calling round and then correcting half the cases, for example gnasher729 . Once the n1778 bindings for C are accepted, you can use the roundeven or fromfp to perform this operation without the need to control the rounding mode.