float a = 0;
while (true)
{
a++;
if (a > 16777216)
break; // Will never break... a stops at 16777216
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我解释为什么浮点值在此代码中停止递增16777216?
编辑:
或者更简单:
float a = 16777217; // a becomes 16777216
Run Code Online (Sandbox Code Playgroud) I would like to make some vector computation faster, and I believe that SIMD instructions for float comparison and manipulation could help, here is the operation:
void func(const double* left, const double* right, double* res, const size_t size, const double th, const double drop) {
for (size_t i = 0; i < size; ++i) {
res[i] = right[i] >= th ? left[i] : (left[i] - drop) ;
}
}
Run Code Online (Sandbox Code Playgroud)
Mainly, it drops the left value by drop in case right …