Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu Mask?

Dikenal juga sebagai: mask (bit mask)

Definition 3.11 High School Computer Science · Bab 3 — Integers in the Machine

A mask is a number used with a bitwise operation to select some bits of another number: x & m keeps the bits of x where m has a 11 and clears the others; x | m sets them to 11; x ^ m flips them. The mask 1 << i has a single 11, at position ii.

Clearing bit 5 of x (bits are numbered from 0 on the right). The mask has a 0 at position 5 and 1 elsewhere;  copies every bit of x except that one.
Clearing bit 55 of x (bits are numbered from 00 on the right). The mask has a 00 at position 55 and 11 elsewhere; and copies every bit of x except that one.
The colour 0xF4A261 as three bytes. Red is (c >> 16) & 0xFF, green (c >> 8) & 0xFF, blue c & 0xFF.
The colour 0xF4A261 as three bytes. Red is (c >> 16) & 0xFF, green (c >> 8) & 0xFF, blue c & 0xFF.
Baca dalam konteks →