Compare software version number Functions

Source: Internet
Author: User

Compare the version number function of the software. The version number is in the form of 3 .. 0.2.1 and supports an unlimited number of bits.

 

/* ++

Routine description:

1. Compare the version number and implement Recursion

History:

13-November-2007-Liu juncong-create

--*/
Bool cupdatefun: isnewversion (cstring stroldversion, cstring strnewversion)
{
If (stroldversion = _ T ("") & strnewversion = _ T (""))
{
Return false; // equal, not a new version
}

Int oldver = 0; // obtain the first version of the old version
Int newver = 0; // obtain the first version of the new version.
Int posoldver = 0; // bitwise, used for the old version
Int posnewver = 0; // bitwise, used for the new version

Posoldver = stroldversion. Find (_ T ("."), 0 );
Oldver = posoldver <0? Atoi (stroldversion): atoi (stroldversion. Left (posoldver ));

Posnewver = strnewversion. Find (_ T ("."), 0 );
Newver = posnewver <0? Atoi (strnewversion): atoi (strnewversion. Left (posnewver ));

If (oldver <newver)
{
Return true;
}
Else if (oldver = newver)
{
Cstring stroldversion1 = _ T (""); // old version
Cstring strnewversion1 = _ T (""); // New Version

If (posoldver>-1)
{
Stroldversion1 = stroldversion. Right (stroldversion. getlength ()-posOldVer-1 );
}

If (posnewver>-1)
{
Strnewversion1 = strnewversion. Right (strnewversion. getlength ()-posNewVer-1 );
}

Return isnewversion (stroldversion1, strnewversion1 );
}

Return false;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.