| 292 | // rounds the number to the nearest integer |
| 293 | FORCE_INLINE |
| 294 | gdv_float64 bround_float64(gdv_float64 num) { |
| 295 | gdv_float64 round_num = round(num); |
| 296 | gdv_float64 diff_num = round_num - num; |
| 297 | if ((diff_num != 0.5) && (diff_num != -0.5)) { |
| 298 | return round_num; |
| 299 | } |
| 300 | if (fmod(round_num, 2.0) == 0.0) { |
| 301 | return round_num; |
| 302 | } |
| 303 | |
| 304 | return num - diff_num; |
| 305 | } |
| 306 | |
| 307 | // rounds the number to the given scale |
| 308 | #define ROUND_DECIMAL_TO_SCALE(TYPE) \ |