由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to solve too large positive summation go to negative in fortran programming?
相关主题
老掉牙的FORTRAN 编程,在REAL*16中,那个是DBLE的替代函数?Fortran question: FORMAT(3HXY=3I)
fortran 中数值精度怎么保证的?Fortran question in PLC?
【急】JS round 运算出错如何破VB, C++初学者清推荐书籍
print double auto precision?Intel Fortran 如何控制不换行?想念Pascal的writeln了
问一道(大)数据 algorithm (转载)Help -- How to output error messages to a file for scripts called by system calls???
another simple question请教一个排序的问题。
How does YAHOO calculate RSI? (转载)any way to use regex in Fortran?
how to read CPU time in FortranFortran father John Backus, dead at 82
相关话题的讨论汇总
话题: negative话题: fortran话题: positive话题: data话题: solve
进入Programming版参与讨论
1 (共1页)
l********r
发帖数: 175
1
I wrote Fortran program to calculate the average and standard deviations of
a large number of data. It turned out that the instantaneous results are
always positive, then the last several sets of average values became
negative. I think it is because the total sum of those data reached the
limit of computer. So it began to show negative results.
I define the type of data as double precision. Is there anyone knows how to
solve the problem? Thanks a lot.
f*******y
发帖数: 988
2
scale一下 if 精度不是啥concern

of
to

【在 l********r 的大作中提到】
: I wrote Fortran program to calculate the average and standard deviations of
: a large number of data. It turned out that the instantaneous results are
: always positive, then the last several sets of average values became
: negative. I think it is because the total sum of those data reached the
: limit of computer. So it began to show negative results.
: I define the type of data as double precision. Is there anyone knows how to
: solve the problem? Thanks a lot.

l***8
发帖数: 149
3
I bet it is not the fault of "double precision" data. The "double precision"
data are floating point. Their range is extremely wide (IEEE double can be
up to 1e307) and it is not possible to overflow from positive to negative (
you will only get a +NaN).
I think you're seeing negative numbers because the "count" is an integer and
FORTRAN calculates the average as (double)"sum" / (int)"count". If you have
more than 2 billion data entries (or 4 billion if the "count" is unsigned),
you'll see negat
1 (共1页)
进入Programming版参与讨论
相关主题
Fortran father John Backus, dead at 82问一道(大)数据 algorithm (转载)
fortran中dm有什么特殊含义吗another simple question
推荐一个找电子书的地方[zt]How does YAHOO calculate RSI? (转载)
Interfacing Microsoft Excel VBA with FORTRAN (转载)how to read CPU time in Fortran
老掉牙的FORTRAN 编程,在REAL*16中,那个是DBLE的替代函数?Fortran question: FORMAT(3HXY=3I)
fortran 中数值精度怎么保证的?Fortran question in PLC?
【急】JS round 运算出错如何破VB, C++初学者清推荐书籍
print double auto precision?Intel Fortran 如何控制不换行?想念Pascal的writeln了
相关话题的讨论汇总
话题: negative话题: fortran话题: positive话题: data话题: solve