Jim Dougherty wrote: > [email protected] wrote: >> ankur_sh2001 wrote: >>> how to add 4 long integers >>> like >>> 562715478678943549...........100 times >>> 562715478678943549...........100 times >>> 562715478678943549...........100 times >>> 562715478678943549...........100 times >> That will exceed the size of an unsigned 64-bit integer. For working >> with really large numbers, you will need an arbitrary precision math >> library. >> >> BTW, 562715478678943549 * 100 = 56271547867894354900...multiplying by >> 10^n is easy - tack the number of zeros corresponding to 'n' onto the >> end of the other number. In this case, two zeros. >> > > Tacking on two zeros to simulate multiplying by 100 works if you care about > displaying the result but it does not work in terms of storing the result > unless your number storage is done in base 10. > > For computers that store things in collections of binary bits the following > are easy: > - Simulate multiplying by 2 by adding 1 zero bit (left shift by 1) > - Simulate multiplying by 4 by adding 2 zero bit (left shift by 2) > - Simulate multiplying by 8 by adding 3 zero bit (left shift by 3) > - Simulate multiplying by 16 by adding 4 zero bit (left shift by 4) > - and so on.
I was just pointing out that a for-loop of adding '562715478678943549' 100 times is not necessary. At least it sounded like a for-loop was going to be involved. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
