I have a portion of a calculation which turns a triplet of double-precision coordinates (x,y,z), into an integer index. To do this, I am using an integer cast, of the form
int cx = (int)(x/dx);. In testing, however, this seems much slower than I would expect; mere division is much faster.
Is there a reason why this operation takes so long? Is there a way of making it faster?