Hi all,
Can anyone tell me why im getting the error : " Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists (are you missing a cast?) "? The compiler is highlighting the 1.0f but thats a float and i already declared magSq a float so im guessing its something to do with the sqrt method....? Im sure this is something simple but new to c# so please help guys!!! Thanks in advance as always for your help with this. Ben.
public void normalize()
{
float magSq = x * x + y * y + z * z;
if (magSq > 0.0f)//check for divide by zero and zero vectors
{
float oneOverMag = 1.0f / System.Math.Sqrt(magSq);
x *= oneOverMag;
y *= oneOverMag;
z *= oneOverMag;
}
}
Can anyone tell me why im getting the error : " Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists (are you missing a cast?) "? The compiler is highlighting the 1.0f but thats a float and i already declared magSq a float so im guessing its something to do with the sqrt method....? Im sure this is something simple but new to c# so please help guys!!! Thanks in advance as always for your help with this. Ben.
public void normalize()
{
float magSq = x * x + y * y + z * z;
if (magSq > 0.0f)//check for divide by zero and zero vectors
{
float oneOverMag = 1.0f / System.Math.Sqrt(magSq);
x *= oneOverMag;
y *= oneOverMag;
z *= oneOverMag;
}
}