[英]Fortran overflow algorithm
I need to know, what is the problem with my overflow algorithm?, In Fortran I have to do an algorithm to return the number of the increment "n" when it reach the overflow break. 我需要知道,我的溢出算法有什么问题?在Fortran中,我必须执行一种算法,以在达到溢出中断时返回增量“ n”的数字。
program overflow
integer::n,i,fact;
fact = 1;
n = 50;
do i=1,n,1
fact=fact*i;
if ((fact==abs(fact)).and.(fact /= 0)) then
print*,"F!=",fact;
n=n+1;
!print*,"Overflow=",n;
end if;
end do;
print*,n;
end program overflow
Its contains negative values, and "mutations" in factorial before reach the number that means "overflow", but it's false, n should be 15. 它包含负值,并且在达到表示“溢出”的数字之前的阶乘中的“突变”,但是它是错误的,n应该为15。
我从没做过Fortran程序员,但是也许您的返回值应该是两倍。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.