comparison bn_mp_lcm.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35

Initial import of libtommath 0.35
author Matt Johnston <matt@ucc.asn.au>
date Fri, 06 May 2005 08:59:30 +0000
parents d29b64170cf0
children
comparison
equal deleted inserted replaced
142:d29b64170cf0 190:d8254fc979e9
26 return res; 26 return res;
27 } 27 }
28 28
29 /* t1 = get the GCD of the two inputs */ 29 /* t1 = get the GCD of the two inputs */
30 if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) { 30 if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
31 goto __T; 31 goto LBL_T;
32 } 32 }
33 33
34 /* divide the smallest by the GCD */ 34 /* divide the smallest by the GCD */
35 if (mp_cmp_mag(a, b) == MP_LT) { 35 if (mp_cmp_mag(a, b) == MP_LT) {
36 /* store quotient in t2 such that t2 * b is the LCM */ 36 /* store quotient in t2 such that t2 * b is the LCM */
37 if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) { 37 if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
38 goto __T; 38 goto LBL_T;
39 } 39 }
40 res = mp_mul(b, &t2, c); 40 res = mp_mul(b, &t2, c);
41 } else { 41 } else {
42 /* store quotient in t2 such that t2 * a is the LCM */ 42 /* store quotient in t2 such that t2 * a is the LCM */
43 if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) { 43 if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
44 goto __T; 44 goto LBL_T;
45 } 45 }
46 res = mp_mul(a, &t2, c); 46 res = mp_mul(a, &t2, c);
47 } 47 }
48 48
49 /* fix the sign to positive */ 49 /* fix the sign to positive */
50 c->sign = MP_ZPOS; 50 c->sign = MP_ZPOS;
51 51
52 __T: 52 LBL_T:
53 mp_clear_multi (&t1, &t2, NULL); 53 mp_clear_multi (&t1, &t2, NULL);
54 return res; 54 return res;
55 } 55 }
56 #endif 56 #endif