andrewroz, Use the NCD function. It will give you the value of the most significant bit set.
It's in the manual.....

Dave Purola,
N8NTA