@@ -56,7 +56,7 @@ int main()
5656 long int intLenProcessed, carryIndex;
5757
5858 base1 = 10 ;
59- base2 = 2 ;
59+ base2 = 16 ;
6060
6161 maxDigitBase2 = base2 - 1 ;
6262
@@ -92,6 +92,7 @@ int main()
9292 cin >> base2;
9393 cout << " FRACTION LIMIT = " ;
9494 cin >> fractionLimit;
95+ maxDigitBase2 = base2 - 1 ;
9596 goto begining;
9697 }
9798 else if (choice == 3 )
@@ -137,7 +138,7 @@ int main()
137138
138139 cout << " please wait(processing...)" << endl;
139140
140- fractionInputLen = integerInputLen - p;
141+ fractionInputLen = integerInputLen - p - 1 ;
141142 integerInputLen = p;
142143
143144 carryIndex = 1 ;
@@ -160,8 +161,9 @@ int main()
160161 {
161162 integerWork[idx+1 ] += integerWork[idx] / base2;
162163 integerWork[idx] %= base2;
163- if (carryIndex < ++idx) carryIndex = idx ;
164+ idx++ ;
164165 }
166+ if (carryIndex < idx) carryIndex = idx;
165167 }
166168 intLenProcessed = carryIndex;
167169 }
@@ -171,7 +173,7 @@ int main()
171173 // ---------------------------------------------------
172174 long int fractionResultIndex = -1 ;
173175 bool fractionNotZero = true ;
174-
176+ int maxi= 0 ;
175177 // Only run fractional loop if there was a fractional part in the input
176178 if (fractionInputLen > 0 )
177179 {
@@ -181,18 +183,18 @@ int main()
181183 {
182184 fractionWork[p] *= base2;
183185 }
184- for (i = 0 ; i < fractionInputLen - 1 ; i++)
186+ for (i = 0 ; i < fractionInputLen; i++)
185187 {
186188 fractionWork[i + 1 ] += fractionWork[i] / base1;
187189 fractionWork[i] %= base1;
188190 }
189191
192+
190193 // store extracted digit
191- fractionOut[++fractionResultIndex] = fractionWork[fractionInputLen - 1 ];
194+ fractionOut[++fractionResultIndex] = fractionWork[fractionInputLen];
192195
193196 // CORRECT: clear working buffer (not fractionOut)
194- fractionWork[fractionInputLen - 1 ] = 0 ;
195-
197+ fractionWork[fractionInputLen] = 0 ;
196198 fractionNotZero = false ;
197199 for (p = 0 ; p < fractionInputLen; p++)
198200 {
@@ -216,7 +218,7 @@ int main()
216218
217219 cout << endl << " EQUIVALENT TO (base)" << base2 << endl;
218220 display (highestIntPos, fracLen);
219-
221+ cout<< " MAX= " <<maxi<<endl;
220222 goto begining;
221223
222224 return 0 ;
0 commit comments