Change Your Codes Behavior By Using Bitwise Operators

Written by silver.io | Published 2020/02/20
Tech Story Tags: hacking | algorithms | programming | binary-code | coding-interview | tutorial | mathematics | math-logic

TLDR The program prints the binary representation of different access mode flags that are used in the open() function. The flags have “values that correspond to single bits”, (Hacking: The Art of Exploitation, Jon Erickson) and consequently, the flags can be added together (using the OR operator) to create new behavior. We use a bit mask (the mask) with a value of 4278190080 (this number requires four bytes) to isolate each byte. The outer loop runs four times — and is in charge of isolating each byte and checking if the msb (most significant bit) is set.via the TL;DR App

no story

Written by silver.io | Engineering, hacking, surfing
Published by HackerNoon on 2020/02/20