[HN Gopher] C Traps and Pitfalls (1988) [pdf]
___________________________________________________________________
C Traps and Pitfalls (1988) [pdf]
Author : aragonite
Score : 25 points
Date : 2024-07-21 01:17 UTC (21 hours ago)
(HTM) web link (literateprogramming.com)
(TXT) w3m dump (literateprogramming.com)
| aragonite wrote:
| Wikipedia article about the book of the same name:
| https://en.wikipedia.org/wiki/C_Traps_and_Pitfalls
| pjmlp wrote:
| For all practical purposes, as true in 2024, as in 1988, except
| for the few ones that actually care about using modern analysis
| tooling in their development workflows.
| rk06 wrote:
| "Expect C programming"[1] is a fantastic take on c language. And
| its idiosyncracies
|
| [1] https://www.amazon.in/Expert-Programming-Peter-van-
| Linden/dp...
| vrighter wrote:
| the part about right shift not being equivalent to a division by
| 2 even if sign bits are copied didn't really convince me.
|
| -1/2 = -0.5
|
| floor of that is -1.
|
| -1 >> 1 == -1
|
| What's the issue? It's integers. The floor is implied.
| wahern wrote:
| Integer division rounds to 0, not negative infinity. -1 / 2 ==
| 0, or -0 if you're lucky enough to have the hardware. For ones'
| complement and signed magnitude, though, right shift of a
| negative number also rounds to 0, I think.
| MaxBarraclough wrote:
| I wasn't aware of this gem of C minutiae:
| Compound assignment operators such as += are really multiple
| tokens. Thus, a + /* strange */ = 1 means the
| same as a += 1
___________________________________________________________________
(page generated 2024-07-21 23:15 UTC)