You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using std::round from cmath header file. I want the __round intrinsic function to be used, but I could not find any function supporting just double parameter, there is only long double version which casts the parameter to double anyways.
To use the version with __round intrinsic function I have to cast the parameter to long double otherwise the old C version from math.h (corecrt_math.h) header file is used, which is much slower.
Is there any reason for that or am I doing anything wrong?
constdouble number{ -0.493 };
constauto result{ std::round(number) }; // uses C function from math.hconstauto result{ std::round(static_cast<longdouble>(number)) }; // uses std::round from cmath with __round intrinsic function
I found this issue Use ceil/floor/round/etc. intrinsics so I don't know if this is still in progress, but it's been 4 years since the issue was opened..
The text was updated successfully, but these errors were encountered:
The overload for double is provided by UCRT so it's unfortunate that we can't achieve optimization for it in MSVC STL.
Perhaps we can report this on Developer Community (DevCom). But UCRT seems somehow "frozen" and one of my previous report for conformance bugs was closed for low priority.
While in general we shouldn't expect major changes from the UCRT, @CaseyCarter is currently looking into this area. Additionally, since coordinated changes with the UCRT will almost certainly be necessary to implement C++23/26 constexpr for <cmath> (#2530 and #3789), we're going to have to overhaul this area anyways, so it's the one place where we can reasonably expect UCRT improvements.
I'm using
std::round
from cmath header file. I want the__round
intrinsic function to be used, but I could not find any function supporting justdouble
parameter, there is onlylong double
version which casts the parameter todouble
anyways.To use the version with
__round
intrinsic function I have to cast the parameter tolong double
otherwise the old C version from math.h (corecrt_math.h) header file is used, which is much slower.Is there any reason for that or am I doing anything wrong?
I found this issue Use ceil/floor/round/etc. intrinsics so I don't know if this is still in progress, but it's been 4 years since the issue was opened..
The text was updated successfully, but these errors were encountered: