An assignment I'm currently doing required me to round of a float. I didn't know if there was a standard function for it or not, (if there is I couldn't find it) so I wrote my own.
It works fine but I'm just seeing what people have to say about it. Maybe some tips on improvment.Code:int round(float x){
int y = (int)x;
if((x - y) > 0.5f){
x = (float)++y;
}
else{
x = (float)y;
}
return (int)x;
}