#include <iostream>
using namespace std;
int main()
{
const int sect = 8; //number of segement.
const int startingVol[sect+1] = {0,16,32,64,128,256,512,1024,2048};
// the starting value of every segement.
const int quanIntvl[sect] = {1,1,2,4,8,16,32,64};
//quantity interval of every Segments, 1 equeal to 1/2048.
int pcmInd = 0; //pcm code's index.
int pcmCode[sect] = {0,0,0,0,0,0,0,0}; // 8 bit of pcm codes.
int sampleValue = 1270;
int startPoint; //starting point of the segement starting piont
//such as startingVol[startPoint] = 16 or 128 etc.
int finePoint; //the starting point of inner segement code.
int quanValue; // it's used to store the final quantity value.
int quanError; //error caused by quantity.
//the following four variables is used in geting the segmentCode
int low = 0;
int high = sect;
int mid;
int loopInd1 = 0; //loop index to get segment code