------- Comment #9 from sylvain dot pion at sophia dot inria dot fr  2008-12-09 
20:03 -------
Incidentally, I submitted to WG21 a few days ago a proposal which will appear
in the coming mid-term mailing as N2811, named "Directed Rounding Arithmetic
Operations".  In the meantime, you can find it here:
http://www-sop.inria.fr/members/Sylvain.Pion/cxx/rounded_operations_N2811.pdf

This document proposes the addition of functions like:

--------------------------------------------------------------
template < float_round_style r, FloatingPointLike T, FloatingPointLike U >
requires True<(r != round_indeterminate)>
constexpr auto add(T t, U u) -> decltype(t + u);

Returns: The addition of t and u rounded according to r.
--------------------------------------------------------------

(and similarly for sub, mul, div, sqrt, fma, and int<->float and float<->float
conversions).

With these, it would be possible to explictly attach a rounding mode to an
operation in the source code.  Moreover, their constexpr nature would mean that
they would work for compile-time constants as well.  This would require a bit
of help from the compiler.

That would mean that code which cares about rounding modes would have a way to
say so, and then, other codes can more easily be dealt with (that is: no need
to bother thinking about the effect of -frounding-math on compile-time
constants computations).

(comments on the proposal are welcome, BTW)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36912

Reply via email to