p*******n 发帖数: 273 | 1 if (abs(a)<1e-16)
....
else
{
}
那里错了? 好像不认1e-16. 多谢拉 | p****s 发帖数: 32405 | 2 你的a是啥类型
【在 p*******n 的大作中提到】 : if (abs(a)<1e-16) : .... : else : { : } : 那里错了? 好像不认1e-16. 多谢拉
| k**f 发帖数: 372 | 3
Is it abs(a) or fabs(a)? Also, what is the type of 'a'?
【在 p*******n 的大作中提到】 : if (abs(a)<1e-16) : .... : else : { : } : 那里错了? 好像不认1e-16. 多谢拉
| p*******n 发帖数: 273 | 4 a 是float,
多谢了,abs原型是整型.
【在 k**f 的大作中提到】 : : Is it abs(a) or fabs(a)? Also, what is the type of 'a'?
| k**f 发帖数: 372 | 5
I guess the issue you have is that the 'if' clause never become true, the
program always goes to the 'else' branch. Or it could be the other way
around.
Depending on the actual range of 'a', the 1e-16 may not be a good number to
compare against because the precision of a 32-bit float type is not high
enough. The simplest thing for you to try is to use double as the data type
for 'a' and see if things work.
【在 p*******n 的大作中提到】 : a 是float, : 多谢了,abs原型是整型.
|
|