https://kotlinlang.org logo
#android
Title
# android
o

Ofir Bar

02/14/2020, 11:43 PM
I came across this code inside
AccessibilityEvent
I wonder why the android team choose to represent ints in hexadecimal for static fields. Of course we can’t know why unless we ask the team directly i guess. So, in general, why the use of hexadecimal might be beneficial to represent ints in such case?
a

Andrew

02/15/2020, 5:50 AM
Its useful if the values are used for a bit mask (everything in powers of 2). For simple cases its obvious like 2, 4, 8, 16, etc but less obvious for higher numbers. The last number in the screenshot would be 262144 and if you add a new one its much easier to just know it should be 0x00080000 without opening a calculator.
☝️ 1
t

twisterrob

02/17/2020, 6:39 PM
it really paid off in Gravity.java where the RTL support was added as a high number flag on top of the existing values
3 Views