Question: I'm working on creating Responsive web page using HTML5. Inside HTML5 Head tag, I've title, meta and link tags, is there any recommended best practice for sequencing these tags to get best possible results ? Current structure of the my page is mentioned below. 

```
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-saleable=false;"/>
<meta name="HandheldFriendly" content="True">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>Demo</title>
<link rel="stylesheet" href="/style.css" type="text/css"/>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body style="margin: 0px;">
Content 
</body>
</html>

```

Can you please suggest, if there is any best practice I need to follow, to utilize HTML5 in best possible way for responsive page design?

Answer: 
If you wanted to avoid converting it to a string, you could just keep dividing by 10 to find the most significant digit:

```
int getMostSignificantDigit(int x)
{
    // Need to handle Integer.MIN_VALUE "specially" as the absolute value can't
    // represented. We can hard-code the fact that it starts with 2 :)
    x = x == Integer.MIN_VALUE ? 2 : Math.abs(x);
    while (x >= 10)
    {
        x = x / 10;
    }
    return x;
}

```

I don't know whether this would be faster than Husman's log/pow approach.
**UPDATED** : I now test with a different number on each iteration and I added OldCurmudgeon's solution (the one derived from Bit Twiddling Hacks By Sean Eron Anderson).

I benchmarked different solutions, including Jon Skeet's :) : 

Here is my main method used for this test:

```
public static void main(String[] args){

  long tip = System.currentTimeMillis();

  //Call the test method 10 000 000 times.
  for(int i= 0 ; i< 10_000_000 ; i++){
    //Here I call the method representing the algorithm.
    foo3(i);
  }

  long top = System.currentTimeMillis();

  System.out.println("Total time : "+(top-tip));

}

```

**1)** With the OP's solution : 

```
public static boolean foo1(Integer i){
  return String.valueOf(i).charAt(0) == '2';
}

```

It takes **425 ms** on my computer.

**2)** Try with Integer.toString().startsWith() : 

```
public static boolean foo2(Integer i){
  return Integer.toString(i).startsWith("2");
}

```

It takes **410 ms** on my computer.

**3)** With Husman's solution :

```
public static boolean foo3(Integer i){
  i = Math.abs(i);
  return ((int) Math.floor(i / Math.pow(10, Math.floor(Math.log10(i))))) == 2;
}

```

It takes **2020 ms**.

**4)** With Jon's solution :

```
public static boolean foo4(Integer i){
  return getMostSignificantDigit(i)==2;
}

public static int getMostSignificantDigit(int x)
{
  // TODO: Negative numbers :)
  while (x > 10)
  {
    x = x / 10;
  }
  return x;
}

```

It takes **125 ms**

**5)** With OldCurmudgeon's solution (see her answer):

```
public static boolean foo5(Integer i){
  return OldCurmudgeon.topDigit(i)==2;
}

```

It takes **97 ms**