c - Conversion to ‘int’ from ‘float’ may alter its value -
my code:
#inlcude <math.h> #include "draw.h" /*int draw(int x, int y)*/ draw(rintf(10 * x), rintf(8 * y));
i warning: conversion ‘int’ ‘float’ may alter value.
i can't change draw
float, since need draw points. rounding inevitable. ideas?
the return type of rintf
float
produces warning. can either explicitly cast int
suppress warning (i.e., (int) rintf(10 * x)
, or use way of rounding (e.g., if values known non-negative, (int) (10.0f * x + 0.5f)
) or lrint
(preferably tgmath.h
), although returns long
may cause warning depending on compiler , settings.
Comments
Post a Comment