Math Lib: add iroundf function for: (int)floorf(a + 0.5f)

This commit is contained in:
2014-01-15 12:31:30 +11:00
parent 9e8428b09a
commit da8619fe23
2 changed files with 6 additions and 0 deletions

View File

@@ -231,6 +231,7 @@ MINLINE int is_power_of_2_i(int n);
MINLINE int power_of_2_max_i(int n);
MINLINE int power_of_2_min_i(int n);
MINLINE int iroundf(float a);
MINLINE int divide_round_i(int a, int b);
MINLINE int mod_i(int i, int n);

View File

@@ -151,6 +151,11 @@ MINLINE int power_of_2_min_i(int n)
return n;
}
MINLINE int iroundf(float a)
{
return (int)floorf(a + 0.5f);
}
/* integer division that rounds 0.5 up, particularly useful for color blending
* with integers, to avoid gradual darkening when rounding down */
MINLINE int divide_round_i(int a, int b)