Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29279 Discussions

Another way to avoid the INTEGER OVERFLOW problem

WSinc
New Contributor I
576 Views

The advantage of this method, is:

You don't have to resort to a higher order arithmetic, and you always get the correct result.

integer(8) function two_int(istart,istop,istep)
integer(8) istart,istop,istep,i1m,i2m,i1d,i2d
  i1m=mod(istart,istep)
  i1d=istart/istep
  i2m=mod(istop,istep)
  i2d=istop/istep
  two_int=i2d-i1d+(i2m-i1m+istep)/istep
end function

This method also works for 4 byte quantities.

Or any number of bytes.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
576 Views

Bill, let's try to keep it down to a dozen threads on this topic, ok? Use https://software.intel.com/en-us/forums/topic/542848

 

0 Kudos
Reply