|
-
Jul 9th, 2001, 03:21 PM
#1
Thread Starter
Dazed Member
(-n == ~n + 1)?????
I figured out how to take a negative number in binary and convert it to it's absoulte value with (-n == ~n + 1).
-256 = 1100000000
255 = 0011111111 + 1 = 256
or
-16 = 1111110000
15 = 0000001111 + 1 = 16
ok..... now then. If i want to find a postive numbers negative
counterpart how would i go about doing this? Would this be correct? (n == -n >> 1) This seems to work on random numbers. For instance: 256 = 1000000
-256 = 1100000
but not on every number. How would i go about doing this?
Thanks guys!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|