I need to be able to convert a version string to an integer. I've decided I will follow semantic versioning so version strings will be of the type
Initially I thought a simple algorithm like
int = x * 10^6 + y * 10^3 + z would be sufficient and it most probably will be since I've never seen software with a three digit major/minor/patch value, however theoretically it is possible for such algorithm to fail.
Lets suppose we have versions
1.1000.0, in this case the integers would be
int(2.0.0) = 2 * 10^6 + 0 * 10^3 + 0 = 2000000 int(1.1000.0) = 1 * 10^6 + 1000 * 10^3 + 0 = 2000000
Clearly the algorithm is flawed, I want to ask if there is a known such algorithm that I could use.
Again I would probably be OK performing the calculation this way but I'm interested to find out if there is a bulletproof way?