B

Opération binaire

Les opérations binaires sont des opérations mathématiques qui manipulent directement les bits des nombres binaires.

Binaire operations are fundamental operations that directly manipulate individual bits within binary numbers. These operations are crucial in l'informatique and programming, particularly in low-level programming, de compression de données, and cryptography. The primary bitwise operations include:

  • ET (&): Compares corresponding bits of two numbers and returns a new number whose bits are set to 1 only if both bits at that position are also 1.
  • OU (|): Compares corresponding bits of two numbers and returns a new number whose bits are set to 1 if at least one of the bits at that position is 1.
  • XOR (^): Compares corresponding bits of two numbers and returns a new number whose bits are set to 1 if the bits are different (i.e., one is 1 and the other is 0).
  • NON (~) : Inverse les bits d’un nombre, transformant les 1 en 0 et les 0 en 1.
  • Décalage à gauche (<<): Shifts all bits of a number to the left by a specified number of positions, filling the new rightmost bits with 0s.
  • Décalage à droite (>>): Shifts all bits of a number to the right by a specified number of positions, with the handling of the leftmost bits depending on whether the number is signed or unsigned.

Bitwise operations are particularly efficient because they operate directly on the binary representations of numbers, allowing for rapid calculations and manipulations. They are widely used in various applications, including setting or clearing specific bits in flags, performing arithmetic operations in a more efficient manner, and implementing algorithms for tasks such as traitement d'image et manipulation de données réseau.

oEmbed (JSON) + /