• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Operators > Bitwise Operators

Bitwise Operators

These require a bit of explanation. You can feed any number in base-10 and perform operations using bitwise operators. What happens is the number is converted to a base-2 number as a string, and then logical operators apply to each character in the string. If two operators are involved, the corresponding characters are evaluated according to the operator. The result is then translated back to a base-10 number, according to ECMAScript's numbering system.

In base-2, 7 becomes “111.” 16 becomes “10000.” 5 becomes “101.” The right edges of the numbers line up for any operations, and empty slots are filled with zeroes, up to 32 digits total for all operands.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint