In the original code it samples a texture to generate the noise so I guess the question is what is the GetNoise2D function in your code? 
I’m going to assume that it accesses an array with noise, inputs being the x row and y column in the array (integers).
In that case change your code like so:
float a = GetNoise2D( ((int)p.X+0)&255, ((int)p.Y+0)&255 );
float b = GetNoise2D( ((int)p.X+1)&255, ((int)p.Y+0)&255 );
float c = GetNoise2D( ((int)p.X+0)&255, ((int)p.Y+1)&255 );
float d = GetNoise2D( ((int)p.X+1)&255, ((int)p.Y+1)&255 );
The &255 part insures that the value will be wrapped from 0 to 255 (assuming the noise array is 256x256).