Skip to content

Commit b28e27d

Browse files
committed
Cast before and after call to sqrt
A call to `sqrt` was taking a `size_t` value as input and expecting a `size_t` value as output. This kind of works with C++11, but only with C++11. Even then a `double` is the expected return type. To fix this issue, we convert to a `double` start with. Also as we should have a perfect square going into `sqrt`, we expect to have an integral value coming out (though of `double` type). Then we cast back to `size_t` explicitly to match our intended storage type.
1 parent ae65b58 commit b28e27d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/library/plan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static bool split1D_for_inplace(size_t num, vector<vector<size_t> > &splitNums,
165165

166166
num = num / divide_factor;
167167
//now the remaining num should have even number of pow2, pow3 and pow5 and we can do sqrt
168-
size_t temp = sqrt(num);
168+
size_t temp = (size_t)sqrt((double)num);
169169
vector<size_t> splitVec;
170170
splitVec.push_back(temp*divide_factor);
171171
splitVec.push_back(temp);

0 commit comments

Comments
 (0)