V636. Expression was implicitly cast from integer type to real type. Consider using an explicit type cast to avoid overflow or loss of a fractional part.
V636 The 'timelib_get_current_offset(t) / 3600' expression was implicitly cast from 'long long' 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;. php_date.c 5557
typedef signed long long timelib_sll;
....
timelib_sll timelib_get_current_offset(timelib_time *t);
....
static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS,
bool calc_sunset)
{
double latitude, longitude, zenith, gmt_offset, altitude;
....
if (gmt_offset_is_null) {
gmt_offset = timelib_get_current_offset(t) / 3600; // <=
}
....
}
V636 [CWE-682] The 'width / 2' expression was implicitly cast 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;. gtkcellrendererspinner.c 412
static void
gtk_paint_spinner (GtkStyleContext *context,
cairo_t *cr,
guint step,
int x,
int y,
int width,
int height)
{
GdkRGBA color;
guint num_steps;
double dx, dy;
....
dx = width / 2;
dy = height / 2;
....
cairo_move_to (cr,
dx + (radius - inset) * cos (i * G_PI / half),
dy + (radius - inset) * sin (i * G_PI / half));
cairo_line_to (cr,
dx + radius * cos (i * G_PI / half),
dy + radius * sin (i * G_PI / half));
....
}
Similar errors can be found in some other places:
V636 The 'rect.getHeight() / 16' expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. hud.cpp 771
void drawItemStack(....)
{
float barheight = rect.getHeight() / 16;
float barpad_x = rect.getWidth() / 16;
float barpad_y = rect.getHeight() / 16;
core::rect<s32> progressrect(
rect.UpperLeftCorner.X + barpad_x,
rect.LowerRightCorner.Y - barpad_y - barheight,
rect.LowerRightCorner.X - barpad_x,
rect.LowerRightCorner.Y - barpad_y);
}
V636 The '_t1.tv_sec * 1000000' expression was implicitly cast from 'long' type to 'float' type. Consider utilizing an explicit type cast to avoid overflow. An example: double A = (double)(X) * Y;. scim_utility.cpp 1492
__extension__ typedef long int __time_t;
__extension__ typedef long int __suseconds_t;
struct timeval
{
__time_t tv_sec;
__suseconds_t tv_usec;
};
static struct timeval _t0 = {0, 0};
static struct timeval _t1;
void ISF_PROF_DEBUG_TIME (....)
{
....
etime = ((_t1.tv_sec * 1000000 + _t1.tv_usec) -
(_t0.tv_sec * 1000000 + _t0.tv_usec))/1000000.0;
....
}
Similar errors can be found in some other places:
V636 The '(tv->tv_usec - now.tv_usec) / 1000' expression was implicitly cast from 'long' 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;. ecore_audio_pulse_ml.c 175
pa_time_event *
_ecore_pa_time_new(...., const struct timeval *tv, ....)
{
pa_time_event *event;
struct timeval now;
double interval;
....
interval = (tv->tv_sec - now.tv_sec) +
(tv->tv_usec - now.tv_usec) / 1000;
....
}
Similar errors can be found in some other places:
V636 The expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. gui backgroundwidget.cpp 28
class QSize
{
....
inline int width() const;
inline int height() const;
....
};
void BackgroundWidget::paintEvent(QPaintEvent *_e)
{
....
QSize pixmapSize = pixmapToDraw_.size();
float yOffset =
-(pixmapSize.height() - currentSize_.height()) / 2;
float xOffset =
-(pixmapSize.width() - currentSize_.width()) / 2;
....
}
Similar errors can be found in some other places:
V636 The '1 / 100' expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. gl_rendertarget.cpp 245
float CRenderTarget::im_noise_time;
CRenderTarget::CRenderTarget()
{
....
param_blur = 0.f;
param_gray = 0.f;
param_noise = 0.f;
param_duality_h = 0.f;
param_duality_v = 0.f;
param_noise_fps = 25.f;
param_noise_scale = 1.f;
im_noise_time = 1/100;
im_noise_shift_w = 0;
im_noise_shift_h = 0;
....
}
V636 The 'alphafactor / 100' expression was implicitly casted from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. TabSRMM themes.cpp 1753
void CSkin::setupAeroSkins()
{
....
BYTE alphafactor = 255 - ((m_dwmColor & 0xff000000) >> 24);
....
fr *= (alphafactor / 100 * 2.2);
....
}
Similar errors can be found in some other places:
V636 The 'rand() / 0x7fff' expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. cpp-tests physicstest.cpp 307
static inline float frand(void)
{
return rand()/RAND_MAX;
}
This function was discovered among the source files referring to tests. The programmer most likely wanted real numbers to be returned within the range 0.0f - 1.0f, but the rand() function's return value is an integer number, which means its real component is truncated after division. So the function returns only 0.0 or 1.0. Moreover, since the rand() function returns a value between 0 and RAND_MAX, getting number 1.0 is almost improbable.
V636 The '1 / 2' expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. libtesseract303 language_model.cpp 1163
void LanguageModel::FillConsistencyInfo(....)
{
....
float gap_ratio = expected_gap / actual_gap;
if (gap_ratio < 1/2 || gap_ratio > 2) {
consistency_info->num_inconsistent_spaces++;
....
}
Similar errors can be found in some other places:
V636 The 'packet.pkOrientation.orAzimuth / 10' expression was implicitly cast 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;. qwindowstabletsupport.cpp 467
typedef struct tagORIENTATION {
int orAzimuth;
int orAltitude;
int orTwist;
} ORIENTATION, *PORIENTATION,
NEAR *NPORIENTATION, FAR *LPORIENTATION;
bool QWindowsTabletSupport::translateTabletPacketEvent()
{
....
const double radAzim =
(packet.pkOrientation.orAzimuth / 10) * (M_PI / 180);
....
}
Similar errors can be found in some other places:
V636 The 'i / 4' expression was implicitly cast 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;. mpegaudio_tablegen.h 48
static void mpegaudio_tableinit(void)
{
int i, value, exponent;
for (i = 1; i < TABLE_4_3_SIZE; i++) {
double value = i / 4;
....
}
Similar errors can be found in some other places:
V636 The 'tr / 10' expression was implicitly cast 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;. SpectralLMM5Interface.cpp 198
int SpectralLMM5Interface::GetTransmission(....,
double& transmission)
{
....
int16_t tr = 0;
memcpy(&tr, answer + 1, 2);
tr = ntohs(tr);
transmission = tr/10;
....
}
V636 The '(rand() % 100) / 100' expression was implicitly cast 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;. aiaircraft.cxx 780
bool FGAIAircraft::fpExecutable(time_t now) {
double rand_exec_time = (rand() % 100) / 100;
return (dt_count > (0.1+rand_exec_time)) &&
(fp->isActive(now));
}
Similar errors can be found in some other places:
V636 The 'ACE_CU64_TO_CU32(this->min_) / gsf' expression was implicitly cast 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;. latency_stats.h 73
inline ACE_UINT32
ACE_CU64_TO_CU32 (ACE_UINT64 n)
{
return static_cast<ACE_UINT32> (n);
}
inline void
Latency_Stats::dump_results (const ACE_TCHAR *test_name,
const ACE_TCHAR *sub_test)
{
....
double min_usec = ACE_CU64_TO_CU32 (this->min_) / gsf;
....
}
Similar errors can be found in some other places:
V636 The 'total_size_ / 1024' expression was implicitly cast 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;. hydrogen.cc 11023
unsigned total_size_;
double source_size_in_kb =
static_cast<double>(source_size_) / 1024;
void HStatistics::Print() {
....
double normalized_size_in_kb = source_size_in_kb > 0
? total_size_ / 1024 / source_size_in_kb
: 0;
PrintF("%32s %8.3f ms %7.3f kB allocated\n",
"Average per kB source",
normalized_time, normalized_size_in_kb);
}
Similar errors can be found in some other places:
V636 The expression was implicitly cast from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid overflow. An example: double A = (double)(X) * Y;. sbutmprojection.cpp 56
void
SbUTMProjection::project(....) const
{
....
//Make sure the longitude is between -180.00 .. 179.9
double LongTemp =
(int(LongRad.deg())+180)-
int((int(LongRad.deg())+180)/360)*360-180;
....
}
V636 The expression was implicitly cast from 'int' type to 'float' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. Client (HL2) detailobjectsystem.cpp 1480
virtual int GetMappingWidth( ) = 0;
virtual int GetMappingHeight( ) = 0;
void CDetailObjectSystem::LevelInitPreEntity()
{
....
float flRatio = pMat->GetMappingWidth() /
pMat->GetMappingHeight();
....
}
Similar errors can be found in some other places:
V636 The 'sTrk1 / qTrk1' expression was implicitly cast 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;. g4xaqmtotal.cc 103
G4double G4XAqmTotal::CrossSection(
const G4KineticTrack& trk1, const G4KineticTrack& trk2) const
{
....
G4int sTrk1 = ....;
G4int qTrk1 = ....;
G4double sRatio1 = 0.;
if (qTrk1 != 0) sRatio1 = sTrk1 / qTrk1;
....
}
Similar errors can be found in some other places:
V636 The '1 / (t + 1)' expression was implicitly cast 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
typedef size_t Size;
typedef double DoubleReal;
void updateMeanEstimate(const DoubleReal & x_t,
DoubleReal & mean_t, Size t)
{
DoubleReal tmp(mean_t);
tmp = mean_t + (1 / (t + 1)) * (x_t - mean_t);
mean_t = tmp;
}
V636 The 'iwidth / actual_width[i]' expression was implicitly cast 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;. context.cpp 712
void CContext::TextOut(....)
{
int *actual_width = new int[len];
double max_adjust = max_char_adjust;
int iwidth;
....
if (iwidth / actual_width[i] < 1.0 - max_adjust)
....
}
Similar errors can be found in some other places:
V636 The 'used_count_ / rts_.size()' expression was implicitly cast 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;. rtcalculator.cxx 6406
double RTCalculator::getUsedForGradientRate() {
if (rts_.size() > 0)
return used_count_ / rts_.size();
return 0.;
}
Similar errors can be found in some other places:
V636 The '22 / 7' expression was implicitly cast 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;. kcs.c 239
NTSTATUS
KcsAddTrignometricInstance (....)
{
....
Angle = (double)(Timestamp.QuadPart / 400000) *
(22/7) / 180;
....
}
V636 The 'cfg_grouplimit / cfg_n_connections' expression was implicitly cast 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;. test-ratelim.c 242
static int cfg_grouplimit = 0;
static int cfg_n_connections = 30;
static int
test_ratelimiting(void)
{
double expected_avg_persec = -1.0;
....
expected_avg_persec = cfg_grouplimit / cfg_n_connections;
....
}
V636 The '16 / 116' expression was implicitly cast 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;. color.c 125
psd_argb_color psd_alab_to_color(....)
{
psd_double var_z;
....
var_z = ( var_z - 16 / 116 ) / 7.787;
}
According to the rules of integer division, 16 / 116 == 0. That's why the result will be incorrect.