GithubHelp home page GithubHelp logo

bitsops's Introduction

BitsOps

Repo dedicated to notes on bitwise operators & direct bits manipulation

the EISA EDID edition tool is not yet written, only one helper that generates a valid manufacturer name from 3 chars

for the Hexobfusc tool, visite the following link

https://cdn.rawgit.com/stephaneAG/BitsOps/master/encoderDecoderWip.html R: to update it: https://developer.mozilla.org/en-US/docs/Web/API/Blob

to thoroughly DIGG !

Reminders

_ & - bitwise and
_ | - bitwise or
_ ^ - bitwise xor
_ ~ - bitwise not
_ << - bitwise shift left unsigned
_ >> - bitwise shift right unsigned
_ >>> - bitwise shift right signed

_ 0x.. - hex / base 16
_ 0b.. - bin / base 2

Tips

get the n bit

(x>>n) & 1

odd or even ?

if ((x & 1) == 0) {
  // even
}
else {
  // is odd
}

set n bit

y = x | (1<<n)

unset n bit

y = x & ~(1<<n)

toggle n bit

y = x ^ (1<<n)

is n bit set ?

if (x & (1<<n)) {
  // n-th bit is set
}
else {
  // n-th bit is not set
}
// or
(x & (1<<n) != 0) ? 'set' : 'not set'

turn off right-most set bit

y = x & (x-1)

turn on rigght-most unset bit

y = x | (x+1)

isolate right-most set bit

y = x & (-x)

isolate right-most unset bit

y = ~x & (x+1)

right propagate right-most set bit

y = x | (x-1)

bitsops's People

Contributors

stephaneag avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.