News for hackers. Stuff that matters.
Re:Learn C The Hard Way by irahul on Saturday July 02, 2011 @11:50PM (#2723025)
> "v" is now 9, and to really understand it one must grasp how numbers are represented in binary under the hood.

Correct me if I am wrong, but I don't think C guarantees anything about the binary representation. Depending on the architecture, `v` can have different value.

Re:Learn C The Hard Way by spc476 on Sunday July 03, 2011 @01:10AM (#2723124)
C allows differences in how negative integers are represented (at least, C89 did---I'm not sure about C99 as I don't have the standard in front of me). There are three different ways to represent negative numbers in binary, sign magnitude, one's complement, and two's complement (these days, most computers are two's complement). The upshot is that you might end up with two type of zeros (sign magnitude, one's complement) or an unequal range of negative numbers (two's complement has one additional negative number) and taking the absolute value of an integer may not be possible for some values (given a 16-bit integer on a two's complement system, you cannot get the absolute value for -32,768, which is a valid integer on such a system).
Re:Learn C The Hard Way by bad_wolf on Sunday July 03, 2011 @12:06AM (#2723046)
If 19 is represented differently in binary on your platform than (leading zeros)10011, you are already quite screwed.

You might be thinking of character representation for the later example.

Re:Learn C The Hard Way by irahul on Sunday July 03, 2011 @01:18AM (#2723135)
No, I was thinking binary 19. Does C say the implementation is going to be 1s complements, 2s complements or whatever?

Is there anything that says, for example, it can't be BCD?

Re:Learn C The Hard Way by justincormack on Sunday July 03, 2011 @05:33AM (#2723413)
Yes even though this is exactly why people want to use C now, to get exact binary behaviour.