Forum Discussion
Altera_Forum
Honored Contributor
19 years agoround function
Hi, I want to round a floating point number before I cast it to an int. So, round 3.6 to 4.0 I try using the function round and the compiler buys it but when I do round(3.6) or r...
Altera_Forum
Honored Contributor
19 years agohow about:
float x = 3.6; int y; y = (int)(x + 0.5); // (3.6+0.5 = 4.1 which will get dragged down to 4)