On pre-DX10 hardware, the differences between ATI, NVIDIA and Intel hardware can give different results with the same shader, so your code may be right, but the float point differences maybe the reason you aren’t getting the result you expect. There are instances where you’ll have to use floor/ceil. But yes, it does look like homework. This post will guide you in the right direction.