The result could be up to 8 limbs, which is why you should allocate 8 limbs for c. The top limb might turn out to be zero of course.
The easiest way to print the result is to use gmp_printf with the %N option for mpn's. You need to also give it the number of limbs, as documented on pages 67-68 of our documentation. Bill. On 23 November 2012 00:55, mgundes <mg...@hotmail.com> wrote: > > Hi, > > I am not good at arithmetic but I need to calculate multiplication of big > numbers. I will try to explain my need: > > For instance, if I have two 128 bit numbers represented with arrays below: > > unsigned int a[4] = {100, 20, 30, 40}; > unsigned int b[4] = {200, 10, 5, 120}; > unsigned int c[4] = {0,0,0,0}; > > I want to multiply a and b, then assign the result to the c: > > mpn_mul_n((mp_limb_t *)c, (const mp_limb_t *)a, (const mp_limb_t *)b, > 4); > > Since mpn_mul takes result pointer as mp_limb_t type, then what if result > exceeds? I mean the result of two integer multiplication probably exceeds > integer size. Is there any example for multiplication of big numbers? I > tried mpn_mul_n() as above and used mpn_get_str to see the result but I > guess I could not use correctly. > > Kind regards, > Thanks > > -- > MahmutG > > -- > You received this message because you are subscribed to the Google Groups > "mpir-devel" group. > To post to this group, send email to mpir-devel@googlegroups.com. > To unsubscribe from this group, send email to > mpir-devel+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/mpir-devel?hl=en. -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To post to this group, send email to mpir-devel@googlegroups.com. To unsubscribe from this group, send email to mpir-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mpir-devel?hl=en.