Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (CLOSED)
- (This challenge will not be used for any development purposes, these are just fun, small, challenges.)
- (Solutions will be posted at 7/7/2018 (day/month/year) UTC.)
- Implement bitwise not (see bottom for explanation of bitwise not) assuming the function toBinary exists that returns a string with extra zeros filled out (ex: if I input 10, I will get ...0010 (with the ... being 60 zeros), and we are working with 64 bits and integers. I'd like to see code with a function named bnot that I can call to get the result in base 10, NOT BINARY.
- Extra challenge: Why does bitwise not with a positive number give me a negative number in return?
- Explanation on bitwise not:
- Bitwise not turns bits from 0 to 1 and 1 to 0. For example, if we have (assuming this is 16 bit so this doesn't get too long and the 16th bit decides whether the number is positive or negative.)
- 0000 0000 0000 0000
- 0000 0000 0000 0111
- the result will become (THE RESULT MUST BE IN BASE 10!)
- 1111 1111 1111 1111
- 1111 1111 1111 1000
- (edit)
- Note:
- To convert binary back to base 10, use tonumber(myBits, 2).
- (eoe) (end of edit)
- DM @hiimgoodpack#6011 with questions and solutions.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement