title: frac() function not returning correct value in unity/cg shader
body: <p>I've been playing with a noise function as part of a shader I'm using and encountered something I don't understand with regards the <code>frac()</code> function, specifically that it is returning the originally passed in number, rather than just the fractional part.</p>
  
  <p>To debug the issue I created a very simple shader:</p>
  
  <pre><code>Shader "Custom/FracTest" {
      SubShader {
          CGPROGRAM
  
          #pragma surface surf Lambert
          #pragma target 3.0
  
          #include "UnityCG.cginc"
  
          struct Input {
              half3 viewDir;
          };
  
          void surf(Input IN, inout SurfaceOutput o) {
              float4 col = 0;
  
              float n = 1;
              float sinn = sin(n); // ~0.84147
              float hash = sinn * 43758.5453; // ~36821.54621
  
              float floorHash = floor(hash); // 36821
              float fracHash = frac(hash); // should be ~0.54621
  
              float manualFrac = hash - floorHash;
  
              col.r = fracHash == hash ? 1 : 0;
              col.g = floorHash == hash ? 1 : 0;
              col.b = manualFrac == fracHash ? 1 : 0;
  
              o.Albedo = col.rgb;
          }
  
          ENDCG
      }
  
      Fallback "Diffuse"
  }
  </code></pre>
  
  <p>As you can see, this is a Unity Surface shader, however I don't think Unity is at fault here - from looking at the generated fragment shader it hasn't messed with any of the values/datatypes around this bit of code. The values in comments are what I expect the variables to contain.</p>
  
  <p>When this shader runs it simply colours the whole object based on some tests against the result of the functions. In this case my object appears red, meaning the <code>fracHash</code> value is still equal to the original <code>hash</code> value, the <code>floorHash</code> is not equal to it and the <code>manualFrac</code> value is also not equal to <code>fracHash</code> value. </p>
  
  <p>I can't see what I'm doing wrong here, the documentation states there is a float variant of the <code>frac()</code> function, but I can only assume I'm just hitting some precision limit inside the <code>frac()</code> function - if I use smaller numbers it seems to return sensible results. Given it works when I manually extract the fraction, perhaps I'm using higher precision numbers?</p>
  
  <p>Any ideas - am I making some wrong assumption somewhere, or am I just being an idiot :P ?</p>
  
  <p>For now I'm progressing by manually calculating the fraction, but I'd like to understand what I've missed :)</p>