Solution to Problem 2.30 (page 130) - This function is a direct implementation of the rules given to determine whether or not a two’s-complement addition overflows. /* Determine whether arguments can be added without overflow */ | int tadd_ok(int x, int y) { g int sum = x+y; ' | int neg_over = x < 0 && y < 0 && sum >= 0O; i int pos_over = x >= 0 && y >= 0 && sum < O; f return !'neg_over && !pos_over; | | } £ | .\ \‘ ~ Solution to Problem 2.31 (page 130) | ~ Your coworker could have learned, by studying Section 2.3.2, that two’s- complement addition forms an abelian group, and so the expression (x+y)-x will valuate to y regardess of whether or not the addition overflows, and that B
https://files.mastodon.social/media_attachments/files/113/821/958/101/725/134/original/f7365b7cd34e35fb.jpeg