X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/113fbd0d57be3df9bc6ac56b44d8bd154cc90d38..a48013f8c14bb5d291c4b3243a3ee7013832526d:/badge/util/fixed_point.h diff --git a/badge/util/fixed_point.h b/badge/util/fixed_point.h index 05a8c79..8af7e82 100644 --- a/badge/util/fixed_point.h +++ b/badge/util/fixed_point.h @@ -23,12 +23,15 @@ static inline bool fixed_point_eq(fixed_point x, fixed_point y) { return x.data static inline bool fixed_point_ne(fixed_point x, fixed_point y) { return x.data != y.data; } #define FIXED_POINT_I(x, y) { ((x) * 256) + ((y) * 256 / 1000) } +#define FIXED_INT_I(x) FIXED_POINT_I(x, 0) static inline fixed_point FIXED_POINT(unsigned x, unsigned y) { fixed_point r = { ((int) x * 256) + ((int) y * 256 / 1000) }; return r; } +static inline fixed_point FIXED_INT(unsigned x) { return FIXED_POINT(x, 0); } + static inline int fixed_point_cast_int(fixed_point x) { return x.data / 256; } static inline fixed_point fixed_point_min(fixed_point x, fixed_point y) { return fixed_point_lt(x, y) ? x : y; }