Just curious. I did a program in C, with quite an amount of bitwise operations for a variable which defines access controls for a page. I wanna be able to do the same in Javascript only. How can i accomplish this ordeal?
Any help in bit-tweaking in Javascript will help. Remember no costly functions allowed.
JavaScript has the usual assortment of bitwise operators,
|,&,~, etc.; details in the specification.The following sections will be particularly useful:
~)<<and>>)|and&)Note that JavaScript’s numbers are all floating point (see Section 8.5, The Number Type, in the specification), but the bitwise operations are defined in terms of integers. So for instance, the definition of the bitwise NOT operator:
Any decent implementation will be able to handle these efficiently, avoiding unnecessary conversions from
Numberto internal integer and back.