raycast not ignoring layer

hi everyone i was just wandering how to ignore a layer when raycasting?

i have tried using the correct method of 1<<10 but can not get it to work its still hitting other things in my scene, all i want is for the gui to be touched not the background.

this is a posted of my script

var ray = Camera.mainCamera.ScreenPointToRay (touch.position);
 var hit : RaycastHit;
 var layernum = 1 << 10;
 if(Physics.Raycast (ray,hit,layernum)){
 Debug.Log(hit.collider.gameObject.name);

ok just going to answer my own question with a more understandable answer to learners, or at least what worked for me.

here is the code that worked for me it has to have the ray distance in order for it to work this is what stumped me.

if(Physics.Raycast (ray,hit,Mathf.Infinity,1 << 10)){

layernum = ~layernum;

from my answer here : http://answers.unity3d.com/questions/279514/raycast-ignore-trigger-colliders.html

To ignore a layer, Check this link, scroll down to Casting Rays Selectively :

http://docs.unity3d.com/Documentation/Components/Layers.html

// JavaScript example.
function Update () {
  // Bit shift the index of the layer (8) to get a bit mask
  var layerMask = 1 << 8;
  // This would cast rays only against colliders in layer 8.
  // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
  layerMask = ~layerMask;

  var hit : RaycastHit;
  // Does the ray intersect any objects excluding the player layer
  if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), hit, Mathf.Infinity, layerMask)) {
    Debug.DrawRay (transform.position, transform.TransformDirection (Vector3.forward) * hit.distance, Color.yellow);
    print ("Did Hit");
  } else {
    Debug.DrawRay (transform.position, transform.TransformDirection (Vector3.forward) *1000, Color.white);
    print ("Did not Hit");
  }
}