Merge "Fixed rounding logic in TypedValue to handle negative values correctly"

This commit is contained in:
Chet Haase
2016-06-09 00:31:01 +00:00
committed by Android (Google) Code Review

View File

@@ -300,7 +300,7 @@ public class TypedValue {
(data>>COMPLEX_UNIT_SHIFT)&COMPLEX_UNIT_MASK,
value,
metrics);
final int res = (int)(f+0.5f);
final int res = (int) ((f >= 0) ? (f + 0.5f) : (f - 0.5f));
if (res != 0) return res;
if (value == 0) return 0;
if (value > 0) return 1;