If for any reason the input may have a value over 1023 then there would be a problem with the simple equation. But since the that value comes from a specific 10 bits ADC module it defines the upper limit of 1023.

If you want to use it in other cases, a MIN/MAX would be needed.

In any case Henrik's solution is neat and fast.

Ioannis