Posted By

yuconner on 08/03/06


Tagged

math macro


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

copyleft
khouser


integer round function macro


 / Published in: C++
 

  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  

You need to login to post a comment.