[Courses] C Programming For Absolute Beginners, Lesson 2: Fun With Printf, Scanf, Puts, and Variables

Christopher Howard christopher.howard at frigidcode.com
Wed Mar 7 01:17:22 UTC 2012


On 03/06/2012 03:22 PM, Kevin Cole wrote:
> The way to convert a positive binary integer to its negative, is to use the
> "two's complement".  In this case, a complement isn't about telling the
> number how sexy or smart it is. ;-)  It's more akin to the idea that
> certain wines complement certain foods.  In this case it means the opposite
> state of a bit:  The one's complement of 1 is 0 and vice versa.  So, the
> one's complement of 1001 is 0110, the one's complement of 1111 is 0000,
> etc.  Initially, you might be tempted to think we could use the one's
> complement of a number to represent its negative value.  But there are a
> few edge cases where it gets illogical.
> 

Of course, be aware the the method used to represent negative integers
is architecture dependent.

-- 
frigidcode.com
indicium.us



More information about the Courses mailing list