435,294 Members | 2,687 Online
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

# subtration of bytes using array of bytes

 P: 10 Hi. Hers im subtracting two 16bit numbers by using two 8bit num array.In case if first byte of array is less than first byte of second array den i hav to take borrow form second byte of first array.This i could do ..wat my doubt s suppose if i take 4 elements in array and first byte of first array is less than first byte of second array den im gonna take borrow from second byte of first array,if that second byte of first array is 0 den how can i take borrow from third byte of first array..plz suggest me some ints This is the pgm which i did for 2bytes is array Expand|Select|Wrap|Line Numbers #include #define N 2   typedef unsigned char byte;   class Megaint  { private:       byte a[N];      unsigned int R[N]; public:     Megaint();     Megaint(byte m[]);     Megaint operator-(Megaint M);     void ShowMegaint(); };   int sub(byte n1,byte n2,byte n3) {     int N1,N2,N3,N4;     N1=n1;N2=n2;N3=n3;     if((N1>10)&&(N1<100))         N2=N2*100;     else if(N1>100)         N2=N2*1000;     else          N2=N2*10;       N1=N2+N1;     N4=N1-N3;     return N4; }   Megaint::Megaint() {     int i;     for(i=0;iM.a[i])             res.R[i]=a[i]-M.a[i];         else         {                 R1=sub(a[i],a[i+1],M.a[i]);               res.R[i]=R1;               res.R[i]=res.R[i]&0x0ff;               R1=R1>>8;               a[i+1]=R1;             }     }     return res; }     void Megaint::ShowMegaint() {     int i;     cout<<"the ans is "<>A[i];     }       cout<<"enter 2nd elements"<>B[i];     }*/       Megaint first(A),second(B),third;       third=first-second;     third.ShowMegaint();       return 0; } thank u Sep 10 '09 #1