integer round function macro


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #include "math.h"
  2.  
  3. #define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5))
  4. //or
  5. #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.