I need to compare versions of a software. The requirement is that I need to know if a given version is older (smaller), same or newer (higher) than another one.
The version format is XX.X.XX where:
- the first two digits are the major release. Major release can be between 01 and 99.
- The next digit is the minor release and can be between 0 and 9.
- The last two digits are the bugfix release and can be between 00 and 99. There can be no deviation from this format such as letters or two digits minor release.
The method I am using now is comparing each release number (major vs major, minor vs minor, bugfix vs bugfix) and returning a result based on that.
Knowing exactly the constraints of the version string format, can I just simply remove the dots, convert the version string (05211) to an integer and directly compare the two numbers resulted? Is there any case where this method would return an incorrect result?