The Value of 0xFF Number and Its Uses With & Operation in Java Article by Abdallah Sawan
This commit is contained in:
parent
06419d4deb
commit
12b927e2ae
java-numbers-4/src
main/java/com/baeldung/number_0xff
test/java/com/baeldung/number_0xff
@ -15,6 +15,6 @@ public class Number0xff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getAlfa(int rgba) {
|
public static int getAlfa(int rgba) {
|
||||||
return rgba >> rgba & 0xff;
|
return rgba & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class Number0xffUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void givenColor_whenGetRedColor_thenExtractRedColor() {
|
public void givenColor_whenGetRedColor_thenExtractRedColor() {
|
||||||
int rgba = 272214023;
|
int rgba = 272214023;
|
||||||
int expectedValue = 64;
|
int expectedValue = 16;
|
||||||
assertEquals(Number0xff.getRedColor(rgba), expectedValue);
|
assertEquals(Number0xff.getRedColor(rgba), expectedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user