请让我知道以下 C 函数之间的区别。
static int mandel(float c_re, float c_im, int count) {
float z_re = c_re, z_im = c_im;
int i;
for (i = 0; i < count; ++i) {
if (z_re * z_re + z_im * z_im > 4.f)
break;
float new_re = z_re*z_re - z_im*z_im;
float new_im = 2.f * z_re * z_im;
z_re = c_re + new_re;
z_im = c_im + new_im;
}
return i;
}
以及以下
static int mandel(float c_re, float c_im, int count) {
float z_re = c_re, z_im = c_im;
int i;
for (i = 0; i < count; ++i) {
if (z_re * z_re + z_im * z_im > 4.f)
break;
float new_im = 2.f * z_re * z_im;
z_re = c_re + z_re*z_re - z_im*z_im;//I have combined the statements here and removed float new_re
z_im = c_im + new_im;
}
return i;
}
请参阅我对代码更改的评论。该函数为某些输入提供不同的值。由于结合了这两个语句,浮点数是否会出错?