Q:

Solving inequalities containing rounding / integer math

Maybe I just have a mental block and this is really easy, but I'm having a hard time figuring out the following problem:
Given an integer value $p$ and a scaling factor $f \in \mathbb{Q}$, i.e. $f = \frac{n}{d}$, where $n$ and $d$ are integers, I need to find some integer value $x$ such that the following holds:

$ \lfloor xf \rfloor = \lfloor x\frac{n}{d}\rfloor \leq p$
$ \lfloor (x+1)f \rfloor = \lfloor (x+1)\frac{n}{d}\rfloor > p$

where $\lfloor \cdot \rfloor$ means rounding down to the nearest integer.
Obviously, one can simply calculate $ x \approx \lfloor p /f \rfloor = \lfloor p \frac{d}{n} \rfloor $ and then keep increasing or decreasing $x$ until both conditions are satisfied, but I'd prefer a singe-shot solution.
Thinking about it more, I came up with the following guess at a solution, but I'm having a hard time convincing myself that it is generally correct:
$$ x = \lceil (p+1)/f \rceil - 1 = \lceil (p+1)\frac{d}{n} \rceil - 1$$
where $\lceil \cdot \rceil$ means rounding up to the nearest integer.
Are there general rules or tricks on how to manipulate equations that contain rounding?

A:

$$xn<pd+d........(1)$$ and $$(x+1)n\geq pd+d.......(2)$$ Hence, $$\frac{d(p+1)}{n}-1\leq x< \frac{d(p+1)}{n}$$
$x$ is the integer between these two limits. The fact that there is indeed an integer between these two limits stems from the fact that there is an integer within an interva of $1$ between any two real numbers. 

