DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Yuka has posted 4 posts at DZone. View Full User Profile

Macros "round(x)"

08.02.2006
| 17194 views |
  • submit to reddit
        // macros "round(x)"

#include "math.h"

#define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5))
//or
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))