Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 724792d0 authored by Chet Haase's avatar Chet Haase
Browse files

Fixed rounding logic in TypedValue to handle negative values correctly

Simple rounding by +.5 doesn't work for negative values. one-line fix.

Issue #26884580 Resources#getDimensionPixelSize rounds incorrectly for negative values

Change-Id: Ib2314f7e50320dde87d4c5035a59b49e8f015eaf
parent 63e8d8d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -300,7 +300,7 @@ public class TypedValue {
                (data>>COMPLEX_UNIT_SHIFT)&COMPLEX_UNIT_MASK,
                (data>>COMPLEX_UNIT_SHIFT)&COMPLEX_UNIT_MASK,
                value,
                value,
                metrics);
                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 (res != 0) return res;
        if (value == 0) return 0;
        if (value == 0) return 0;
        if (value > 0) return 1;
        if (value > 0) return 1;