I want to do some bit operation in javascript on a variable. I have this numbers:
min: 153391689 (base 10) - 1111111111 (base 8) max: 1073741823 (base 10) - 7777777777 (base 8)
Now I want to use this variable for storing 10 "vars" with options from 0 to 7. For that, I need to get and set every octal digit (meaning 3 bits). Unfortunately, I didn't made it, but I came with something:
var num = 153391689; function set(val, loc) { num |= val << (loc * 3); } function get(loc) { return (num & 7 << loc * 3) / Math.pow(8, loc); } Thank you.
setnever clears any bits.