mcpField
H
how-to-do-bitwise-operations-in-dart

how-to-do-bitwise-operations-in-dart

github.com/rodydavisDevelopment6042 installsUpdated 2w ago
Repository

About how-to-do-bitwise-operations-in-dart

This guide introduces bitwise operations on int and bool values for Dart developers. Examples cover AND, OR, XOR, and their negated forms.

Key features

  1. 01Explain bitwise operations on int
  2. 02Explain bitwise operations on bool
  3. 03Cover AND, OR, and XOR
  4. 04Describe NAND, NOR, and XNOR
  5. 05Provide Dart code examples

Use cases

  1. 01Look up Dart bitwise operator behavior
  2. 02Compare operations on integers and booleans
  3. 03Learn negated logical operations

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/rodydavis/skills --skill how-to-do-bitwise-operations-in-dart

After installing, type/how-to-do-bitwise-operations-in-dartin Claude Code to confirm it loaded.

Details

From the project README

How to do Bitwise operations in Dart

In Dart it is possible to do Bitwise Operations with int and bool types.

AND 

Checks if the left and right side are both true. Learn more.

// int
print(0 & 1); // 0
print(1 & 0); // 0
print(1 & 1); // 1
print(0 & 0); // 0

// bool
print(false & true); // false
print(true & false); // false
print(true & true); // true
print(false & false); // false

OR 

Inclusive 

Checks if either the left or right side are true. Learn more.

// int
print(0 | 1); // 1
print(1 | 0); // 1
print(1 | 1); // 1
print(0 | 0); // 0

// bool
print(false | true); // true
print(true | false); // true
print(true | true); // true
print(false | false); // false
Exclusive 

Checks if both the left or right side are true but not both. Learn more.

// int
print(0 ^ 1); // 1
print(1 ^ 0); // 1
print(1 ^ 1); // 0
print(0 ^ 0); // 0

// bool
print(false ^ true); // true
print(true ^ false); // true
print(true ^ true); // false
print(false ^ false); // false

NAND 

Negated AND operation.

// int
print(~(0 & 1) & 1); // 1
print(~(1 & 0) & 1); // 1
print(~(1 & 1) & 1); // 0
print(~(0 & 0) & 1); // 1

// bool
print(!(false & true)); // true
print(!(true & false)); // true
print(!(true & true)); // false
print(!(false & false)); // true

NOR 

Negated inclusive OR operation.

// int
print(~(0 | 1) & 1); // 0
print(~(1 | 0) & 1); // 0
print(~(1 | 1) & 1); // 0
print(~(0 | 0) & 1); // 1

// bool
print(!(false | true)); // false
print(!(true | false)); // false
print(!(true | true)); // false
print(!(false | false)); // true

XNOR 

Negated exclusive OR operation.

// int
print(~(0 ^ 1) & 1); // 0
print(~(1 ^ 0) & 1); // 0
print(~(1 ^ 1) & 1); // 1
print(~(0 ^ 0) & 1); // 1

// bool
print(!(false ^ true)); // false
print(!(true ^ false)); // false
print(!(true ^ true)); // true
print(!(false ^ false)); // true

Comments

Markdown supported