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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -