Define 'missing/unread/default' value of ultrasonic sensor

My ultrasonic sensor defaults to 0 distance if it gets no measurements within its range. How do I change this to a different value?

Why do you want to change it?

If you really need to, you could do something like this:

if(distance == 0) {
  distance = -1;
}

But I don't see the point in that.

You can make a change to the library you're using but best take a backup copy first.

The only reason I can see to do it is that if you change the number to be max_distance it makes it marginally easier to write code that checks for obstacles in its path. But by easier I mean having one fewer clause in an if statement - not a significant reduction in complexity.