Material and C++

I’m create game about pirates and I need water for it, so I’m trying to implement Gerstner wave function Chapter 1. Effective Water Simulation from Physical Models Equation 1. (tried also 8a)

And I need to do it on both GPU and CPU so I have done this on both and it returns different values?

What’s the difference between HLSL float and C++ float? Can floating precision be problem here?

C++ code:

float AGerstnerSimple::GetWaveHeight(FVector2D position, FVector2D dirrection, float waveLength, float speed, float amplitude, float powerK, float time)
{
	double wi = 2 / waveLength;
	double p = speed * 2 / waveLength;

	double dotResult = dirrection.X * position.X + dirrection.Y * position.Y;
	double result = amplitude * FMath::Sin(FVector2D::DotProduct(dirrection, position) * wi + time * p);

	return result;
}

And HLSL code tried material nodes but I used this to be sure(Use as custom node):

float wi = 2 / WaveLength;
float p = Speed * 2 / WaveLength;

float dotResult = DirrectionX * PositionX + DirrectionY * PositionY; // Here is inaccuracy

//float result = Amplitude * sin(dot(Dirrection, Positionn) * wi + Time * p);
float result = Amplitude * sin(dotResult * wi + Time * p);

return result;

Can somebody help me figure it out?

Thanks for any help!