Understanding Number Systems
A comprehensive guide to binary, octal, decimal, and hexadecimal number systems.
Read GuideConvert numbers between binary, octal, decimal, and hexadecimal bases instantly.
Common binary operations in JavaScript for flag handling and permissions
// Working with binary flags
const READ_PERMISSION = 0b100 // 4
const WRITE_PERMISSION = 0b010 // 2
const EXECUTE_PERMISSION = 0b001 // 1
// Combining flags using bitwise OR
let userPermissions = READ_PERMISSION | WRITE_PERMISSION // 0b110 (6)
// Checking permissions using bitwise AND
const canRead = (userPermissions & READ_PERMISSION) !== 0 // true
const canExecute = (userPermissions & EXECUTE_PERMISSION) === 0 // false
// Toggle permission using XOR
userPermissions = userPermissions ^ EXECUTE_PERMISSION // Add execute
console.log(userPermissions.toString(2)) // '111'
// Practical example: RGB color channels
const red = 0b11111111 // 255
const green = 0b10101010 // 170
const blue = 0b00000000 // 0
console.log(`rgb(${red}, ${green}, ${blue})`) // "rgb(255, 170, 0)"
Instantly convert between different number bases as you type.
Support for Binary (2), Octal (8), Decimal (10), and Hexadecimal (16).
Includes common programming prefixes (0b, 0o, 0x) and code examples.
Automatic validation ensures correct input for each base system.
A comprehensive guide to binary, octal, decimal, and hexadecimal number systems.
Read GuideLearn how to use bitwise operations effectively in programming.
Read GuideUnderstanding hexadecimal color codes and color manipulation in web development.
Read Guide