Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
d0mine
on Jan 11, 2017
|
parent
|
context
|
favorite
| on:
Two's complement – You beauty
Bitwise opetations assume an infinite number of 1s on the left for negative numbers (2s compliment) e.g., ~-1 == 0 (-1 is an infinite number of 1s that are converted to 0 by ~ (invert) operator ).
3 == 011 2 == 010 1 == 001 0 == 000 -1 == ..111 -2 == ..110 -3 == ..101
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: