After a long time of debugging, I found out that this thing was overflowing or unsigned. When it overflowed, the result of subtraction was huge.
If you want to get a negative number, subtract it first and then give the result to an unsigned number, or define it as a signed number. This thing, when I use the ABS macro, confused me.
C language that has been used for more than 10 years.