我看到一些这样的代码:的数字文字使用后缀f
float num2 = ((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z);
float num = 1f/((float) Math.Sqrt ((double) num2));
this.X *= num;
this.Y *= num;
this.Z *= num;
不要紧,如果是这样的?:
float num2 = ((this.X * this.X) + (this.Y * this.Y)) + (this.Z * this.Z);
float num = 1/((float) Math.Sqrt ((double) num2));
this.X *= num;
this.Y *= num;
this.Z *= num;
请问编译器使用(float)/(float)
或尝试使用(double)/(float)
对于第2行的第二个例子?
编辑:顺便说一句会有任何性能差异?
谢谢,还增加了一个小问题。你知道那个吗? – 2011-01-19 21:37:53
@Joan:'double'与'float'操作的速度取决于CPU。 – SLaks 2011-01-19 21:46:36