c++ - 在使用 nextafter C++ stl 时遇到问题
问题描述
这对我来说似乎有点奇怪,所以如果我做错了什么,请告诉我。
我需要使用该std::nextafter
功能。如此处所述:
https ://en.cppreference.com/w/cpp/numeric/math/nextafter
我需要包含的标题是<cmath>
.
我可以在这里非常简单地使用它:http: //cpp.sh/4z4hw
但是如果我现在在 Visual Studio(2015 编译器 v110)中使用相同的代码,编译会失败,并说 nextafter 不是 std 的成员。
我不知道如何继续,任何帮助将不胜感激。
使用 C++11。
附上我使用的代码。
另请注意,我也使用 std::ceil、std::floor 并且它也是 cmath 的成员,但这似乎工作正常。
float ConfigEngine::adjustRenderRegionVal(int heightOrWidth, float
rrVal, uint expectedValue, uint calculatedValue, bool isMin)
{
if (calculatedValue < expectedValue)
rrVal = std::nextafter(rrVal, 1.0f);
else //is greater
rrVal = std::nextafter(rrVal, -1.0f);
uint newRRLowPx;
if (isMin)
newRRLowPx = static_cast<uint>(std::floor(rrVal * heightOrWidth));
else
newRRLowPx = static_cast<uint>(std::ceil(rrVal * heightOrWidth));
if (newRRLowPx != expectedValue)
return adjustRenderRegionVal(heightOrWidth, rrVal, expectedValue, newRRLowPx, isMin);//recursive call
return rrVal;
}
解决方案
推荐阅读
- react-native - React Native 中的渐变滑块?
- html - 引导程序中的导航栏切换不起作用
- python - 如何使用python登录梦幻超级联赛
- python - 如何将 int8 转换为 pytorch 中的二进制表示?
- node.js - Https重定向不起作用弹性beantalk nodejs
- javascript - 解密和流式传输视频
- go - 位操作使有符号整数变为无符号
- opencl - 未找到带有 OpenCL 2.1 NEO CPU 设备的 Ubuntu 20.04 Intel
- google-apps-script - 尝试使用脚本创建 Gmail 草稿时出现异常错误,您能帮我解决这个问题吗?
- mongodb - 在 mongo db 集合中查找过去 24 小时的更新查询执行计数