function decodeAndClamp(value, addend, coefficient, max) {
    value = addend + value * coefficient;
    // Clamp the value to the range
    return value < 0 ? 0 : value > max ? max : value;
  }
Decode and clamp a value. The formula is different from the spec because we
don't decode to float range [0,1], we decode it in the [0,max] range.