question: protected int encode ( double value , double lower , double upper , int nbits ) { if ( value < lower ) return 0 ; int maxval = ( int ) ( Math . pow ( 2 , nbits ) - 1 ) ; if ( value >= upper ) return maxval ; return ( int ) ( ( value - lower ) * ( ( maxval - 0 ) / ( upper - lower ) ) ) ; }
target:  Encode value as an nbits UNSIGNED integer