PVS-StudioWarnings

PVS-Studio warning V636 for OpenMS

Nov 20th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. typedef size_t Size;
  2. typedef double DoubleReal;
  3.  
  4. void updateMeanEstimate(const DoubleReal & x_t,
  5.                         DoubleReal & mean_t, Size t)
  6. {
  7.   DoubleReal tmp(mean_t);
  8.   tmp = mean_t + (1 / (t + 1)) * (x_t - mean_t);
  9.   mean_t = tmp;
  10. }
  11.  
  12. This suspicious code was found in OpenMS project by PVS-Studio static code analyzer.
  13. Warning message is:
  14. V636 The '1 / (t + 1)' expression was implicitly casted from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. masstracedetection.c 129
  15.  
  16. 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