Department of Computer and Information
Science
The University of Mississippi
#define BLOCK_LOW(id,p,n) ((n)/(p)*(id))
#define BLOCK_HIGH(id,p,n) (BLOCK_LOW((id)+1,p,n)-1)
where the division happens before the multiplication.
If you use id*n/p, when n is a billion,
the value of id*n exceeds the maximum value
for a long.