PVS-StudioWarnings

PVS-Studio warning V550 for CPU Identifying Tool

Nov 18th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. void projillum(short* wtab, int xdots, int ydots, double dec)
  2. {
  3.   ...
  4.   s = sin(-dtr(dec));
  5.   x = -s * sin(th);
  6.   y = cos(th);
  7.   ...
  8.   lon = (y == 0 && x == 0) ? 0.0 : rtd(atan2(y, x));
  9. }
  10.  
  11. It's strange to expect 'x' and 'y' to exactly equal 0 after all these calculations.
  12.  
  13. This suspicious code was found in CPU Identifying Tool project by PVS-Studio static code analyzer.
  14. Warning message is:
  15. V550 An odd precise comparison: x == 0. It's probably better to use a comparison with defined precision: fabs(A - B) '<' Epsilon. clock_dll sunalgo.cpp 155
  16.  
  17. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment