various: fix warning -Wimplicit-const-int-float-conversion

This commit is contained in:
Thomas Weißschuh 2023-02-25 04:54:26 +00:00 committed by sfan5
parent 8d67e891ab
commit ed5426c351
3 changed files with 5 additions and 5 deletions

View File

@ -600,7 +600,7 @@ extern const char m_option_path_separator;
#define OPTDEF_FLOAT(f) .defval = (void *)&(const float){f}
#define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d}
#define M_RANGE(a, b) .min = (a), .max = (b)
#define M_RANGE(a, b) .min = (double) (a), .max = (double) (b)
#define OPT_BOOL(field) \
OPT_TYPED_FIELD(m_option_type_bool, bool, field)

View File

@ -1071,7 +1071,7 @@ static int get_obj_properties(void *ta_ctx, char ***keys, js_State *J, int idx)
static bool same_as_int64(double d)
{
// The range checks also validly filter inf and nan, so behavior is defined
return d >= INT64_MIN && d <= INT64_MAX && d == (int64_t)d;
return d >= INT64_MIN && d <= (double) INT64_MAX && d == (int64_t)d;
}
static int jsL_checkint(js_State *J, int idx)
@ -1085,7 +1085,7 @@ static int jsL_checkint(js_State *J, int idx)
static uint64_t jsL_checkuint64(js_State *J, int idx)
{
double d = js_tonumber(J, idx);
if (!(d >= 0 && d <= UINT64_MAX))
if (!(d >= 0 && d <= (double) UINT64_MAX))
js_error(J, "uint64 out of range at index %d", idx);
return d;
}

View File

@ -71,7 +71,7 @@ static void makegauss(struct ctx *k, unsigned int sizeb)
for (unsigned int c = 0; c < k->size2; c++)
k->gauss[c] = 0;
double sigma = -log(1.5 / UINT64_MAX * gauss_size2) / k->gauss_radius;
double sigma = -log(1.5 / (double) UINT64_MAX * gauss_size2) / k->gauss_radius;
for (unsigned int gy = 0; gy <= k->gauss_radius; gy++) {
for (unsigned int gx = 0; gx <= gy; gx++) {
@ -79,7 +79,7 @@ static void makegauss(struct ctx *k, unsigned int sizeb)
int cy = (int)gy - k->gauss_radius;
int sq = cx * cx + cy * cy;
double e = exp(-sqrt(sq) * sigma);
uint64_t v = e / gauss_size2 * UINT64_MAX;
uint64_t v = e / gauss_size2 * (double) UINT64_MAX;
k->gauss[XY(k, gx, gy)] =
k->gauss[XY(k, gy, gx)] =
k->gauss[XY(k, gx, gauss_size - 1 - gy)] =