# Comparing numbers with decimals

I have an issue in AS3 where I need to compare a number of value type Number. I have two Numbers. For example, 3.10 and 3.9

Comparing the two, 3.9 is greater than 3.10 because it drops the 0 and its like comparing 3.9 to 3.1.

That does make sense. I've tried using value type int and uint and its the same result. Is there something I can do to compare the two values that would result in 3.10 being greater than 3.9 without having to like split at the decimal and compare 9 to 10 ?

No.

3.9 is greater than 3.10 - without splitting the decimal points there is no way that 3.10 will be considered a higher number than 3.9.

I assume you're using this for version control, so I'd just like to caution that your version compare code takes all situations into account.

NO, but..

If you use Strings, you could split on dots, compare each number as int.

trace(getHighestVersion("3.9", "2.10")); // output: 3.9

```trace(getHighestVersion("3.9", "3.10"));        // output: 3.10
trace(getHighestVersion("3.9", "3.9"));        // output: 3.9 (same)
trace(getHighestVersion("3.90", "3.10"));        // output: 3.90
trace(getHighestVersion("3.9.2.1", "3.9.1.9")); //output: 3.9.1.9
trace(getHighestVersion("3.9.2.1", "3.9.3.0")); //output: 3.9.3.0

function getHighestVersion(version1:String,version2:String):String
{
var list1:Array = version1.split(".");
var list2:Array = version2.split(".");

if (list1.length != list2.length) trace("not equal lengths: " + version1 + " / " + version2);

for(var i:int = 0, leni:uint = list1.length; i < leni; i++)
{
var num1:uint = uint(list1[i]);
var num2:uint = uint(list2[i]);
if (num1 > num2)
{
return version1;
}
if (num1 < num2)
{
return version2;
}
}
trace("both versions are equal: " + version1 + " / " + version2)
return version1;
}
```

### Regular expression matching a given structure

I need to generate a regex to match any string with this structure:

### Modify behavior of WordPress

I have an own server with WordPress installed on it.