This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/49360] generate wrong logic code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49360

Wu Xingbo <wuxb45 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |mipsel-gnu-linux
               Host|                            |Fedora 15 x86_64
              Build|                            |Fedora 15 x86_64

--- Comment #1 from Wu Xingbo <wuxb45 at gmail dot com> 2011-06-10 06:29:00 UTC ---
long lcm(long num1,long num2)
{
    int a, b, temp;
/***********here*************/
    if(num1<num2) /*want n1>n2*/
    {
        temp=num1; 
        num1=num2;
        num2=temp; /*swap*/
    }
/****************************/
/***generates the logic:*****/
    if(!(num1<num2))
    {
        temp=num1; 
        num1=num2;
        num2=temp; /*swap*/
    }

    a=num1;//big
    b=num2;//small
    while(b!=0) /*gcd*/
    {
        temp=a%b;
        a=b;
        b=temp;
    }
    return num1*num2 / a;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]