由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c 语言中怎么用科学计数法
相关主题
请教关于float的精度和比较请问怎么用C++ import xls格式的数据?
业余说说Golang的问题python descriptor 问题
c++ 中如何把str转换为float?data structure for set of path in a graph
html input如果处理非常大的数怎么搞?Simplest way to iterate array from both ends alternatively?
Need suggestions from your experts!!C ++ 问题
急!怎样判断两个任意4边形是否相交?用python测webpage
2个无序的text文件如何找到第一个相同的line ?Moving from Node.js to Go at Bowery
评估!写多少行程序算多?solidot上看来的
相关话题的讨论汇总
话题: 1e话题: 计数法话题: abs话题: type话题: 16
进入Programming版参与讨论
1 (共1页)
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原型是整型.

1 (共1页)
进入Programming版参与讨论
相关主题
solidot上看来的Need suggestions from your experts!!
help abt C++急!怎样判断两个任意4边形是否相交?
c++ std::abs(int) ambiguous?2个无序的text文件如何找到第一个相同的line ?
如何提取一个executable的所有dependency?评估!写多少行程序算多?
请教关于float的精度和比较请问怎么用C++ import xls格式的数据?
业余说说Golang的问题python descriptor 问题
c++ 中如何把str转换为float?data structure for set of path in a graph
html input如果处理非常大的数怎么搞?Simplest way to iterate array from both ends alternatively?
相关话题的讨论汇总
话题: 1e话题: 计数法话题: abs话题: type话题: 16