How to portably find out min(INT_MAX, abs(INT_MIN))?

While the typical value of INT_MIN is -2147483648, and the typical value of INT_MAX is 2147483647, it is not guaranteed by the standard. TL;DR: The value you’re searching for is INT_MAX in a conforming implementation. But calculating min(INT_MAX, abs(INT_MIN)) isn’t portable. The possible values of INT_MIN and INT_MAX INT_MIN and INT_MAX are defined by the … Read more

undefined reference to `log’

I don’t know what the reason is, but if you move -lm to the end, it will compile. $ cc -o randomselection rfc3797.c MD5.c -lm rfc3797.c: In function ‘getinteger’: rfc3797.c:183:3: warning: format not a string literal and no format arguments [-Wformat-security]

Simple physics-based movement

I found this question very interesting since I had recently done some work on modeling projectile motion with drag. Point 1: You are essentially updating the position and velocity using an explicit/forward Euler iteration where each new value for the states should be a function of the old values. In such a case, you should … Read more

How deterministic is floating point inaccuracy?

From what I understand you’re only guaranteed identical results provided that you’re dealing with the same instruction set and compiler, and that any processors you run on adhere strictly to the relevant standards (ie IEEE754). That said, unless you’re dealing with a particularly chaotic system any drift in calculation between runs isn’t likely to result … Read more

__int64 on a 32-Bit machine?

Same way 32-bit arithmetic worked on 16-bit systems. In this case, it uses 2 32-bit memory addresses to form a 64-bit number together. Addition/substraction is easy, you do it by parts, the only gotcha is taking the carry-over from the lower part to the higher part. For multiplication/division, it’s harder (ie more instructions). It’s obviously … Read more

Is there a difference between a “finite state machine” and a “state machine”?

I’m not sure I understand if there is a difference between a finite state machine and a state machine? Am I thinking about this too hard? Yes, you are thinking about it too hard. 🙂 It depends on context. Obviously, taken literally, the term “finite state machine” indicates a finite number of states, while “state … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)