Corner cases are hard. Here's a little C program; try to figure out what it prints before you compile & run it. It computes a step size between two numbers, given a number of steps:
#include <stdio.h>
int f(unsigned n_steps, int from_val, int to_val){
int step_size = (from_val - to_val) / n_steps;
return step_size;
}
Yeah, they are, but your example is not good enough, it is like an example from a textbook on traps of C.
Corner cases hard when you are trying to do something new, because if you did it before, you'd know the most of them. Or if someone else did it before and wrote a textbook. =)
#include <stdio.h>
int f(unsigned n_steps, int from_val, int to_val){ int step_size = (from_val - to_val) / n_steps; return step_size; }
int main(){ printf("f(3, 0, 30) = %d\n", f(3, 0, 30) ); printf("f(3, 30, 0) = %d\n", f(3, 30, 0) ); }