Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I answered myself as it can be found here. Silly me! The root of the entire problem was the type used in both point.x and point.y: typedef unsigned int uint; typedef struct { uint x; ...
Answer
#2: Post edited
- _I answered myself as it can be found [here](https://stackoverflow.com/a/33534714/5397930)._
- <hr />
- Silly me! The root of the entire problem was the type used in both `point.x` and `point.y`:
- typedef unsigned int uint;
- typedef struct {
- uint x;
- uint y;
- } point;
- As both are unsigned integers, they "wrap up" once they receive a negative value, just like in the MCVE. This gets corrected by just changing `uint` to `int`:
/* typedef unsigned int uint; */- typedef struct {
- int x;
- int y;
- } point;
- So keep this in mind when using signed and unsigned numbers!
- _I answered myself as it can be found [here](https://stackoverflow.com/a/33534714/5397930)._
- <hr />
- Silly me! The root of the entire problem was the type used in both `point.x` and `point.y`:
- typedef unsigned int uint;
- typedef struct {
- uint x;
- uint y;
- } point;
- As both are unsigned integers, they "wrap up" once they receive a negative value, just like in the MCVE. This gets corrected by just changing `uint` to `int`:
- typedef struct {
- int x;
- int y;
- } point;
- So keep this in mind when using signed and unsigned numbers!
#1: Initial revision
_I answered myself as it can be found [here](https://stackoverflow.com/a/33534714/5397930)._ <hr /> Silly me! The root of the entire problem was the type used in both `point.x` and `point.y`: typedef unsigned int uint; typedef struct { uint x; uint y; } point; As both are unsigned integers, they "wrap up" once they receive a negative value, just like in the MCVE. This gets corrected by just changing `uint` to `int`: /* typedef unsigned int uint; */ typedef struct { int x; int y; } point; So keep this in mind when using signed and unsigned numbers!