>Robert Covington wrote: > >> I am told that: >> >> function Noise2(integer x, integer y) >> n = x + y * 57 >> n = (n<<13) ^ n >> return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & >> 7fffffff) / 1073741824.0) >> end function >> >> is supposed to return a random number from -1.0 to 1.0 >> >> >> However when I Basicatize it, I get back >> >> -0.2817909839 >> -0.9999999991 >> -0.9999999991 >> -0.9999999991 >> and so on... >> >> >> Anybody able to fathom this better? > > >local >dim as long n, temp >local fn Noise2#( x as long, y as long ) >n = x + y*57 >n = (n << 13) xor n >temp = (n*(n*n*15731 + 789221) + 1376312589) and 0x7FFFFFFF >end fn = (1.0 - temp/1073741824.0) > > >dim x, y >for x = 1 to 5 >for y = 1 to 5 >print x, y, fn Noise2#( x, y ) >next >next > > >Robert P. Stangely enough... I tried that very combination also after seeing some C2FB 3 output with the XOR and still got only one answer even after precendence arranging...ARGH. I beat my head on this all day yesterday. Is My Machine FRIED? With Register OFF, this RP version works. With Register ON, I get the same result always. TechTool Pro says things are fine....PPC 603ev, OS 8.6 Can somebody write me a register test program to verify that my machine isn't whacked? Register OFF... 1 1 0.22372510377 1 2 0.5656265048 1 3 -0.7552760029 1 4 0.7064104257 1 5 -0.6039213641 2 1 -0.8107898058 2 2 -0.5769988457 2 3 -0.5596013935 2 4 -0.3132046042 2 5 0.6075843675 3 1 -0.4346127445 3 2 0.17258374672 3 3 0.009797130711 3 4 -0.4775797473 3 5 -0.8441540422 4 1 -0.18315571267 4 2 -0.7210377185 4 3 -0.5824924307 4 4 0.6778729958 4 5 -0.4945485936 5 1 0.4081692891 5 2 -0.7932752417 5 3 0.12811792176 5 4 -0.3822583752 5 5 0.12098871265 Register ON 1 1 -0.2817909839 1 2 -0.2817909839 1 3 -0.2817909839 1 4 -0.2817909839 1 5 -0.2817909839 2 1 -0.2817909839 2 2 -0.2817909839 2 3 -0.2817909839 2 4 -0.2817909839 2 5 -0.2817909839 3 1 -0.2817909839 3 2 -0.2817909839 3 3 -0.2817909839 blah blah blah for all