Actually it's quite hard to describe:
I want to implement an algorithm which compares figure by figure of the same position (as I do my calculations in a 10-based system it's rather the same "power of ten") of two given integers/number (with the same "length"). It should return the grade of equality as following:
- 4491 and 1020 = 0
- 4491 and 4123 = 1
- 4491 and 4400 = 2
- 4491 and 4493 = 3
- 4491 and 4491 = 4
- 4491 and 4091 = 1
I do not want to do my calculations based on a string-comparison, as I'll doing this in a way bigger scenario :)
For all cases where X and Y are not equal:
4491 and 1020
4491 and 4493
It sounds like the Levenshtein Distance would be appropriate. This is a standard way to measure the difference between two strings. In your case, the strings are the decimal representations of the numbers.
Just to try to salvage something from this question after my last attempt...
Note: it does not handle negative integers
Update: fixed after question update
See the Answer to this SO Question
You can Split the digits by the first method and Get the Similarity from the Second Method:
Now you can Compare the the two int arrays like this :
I thing the best way to calculate it is using Euclidean Similarity.
Please see this link: http://stackoverflow.com/questions/11555355/calculating-the-distance-between-2-points