Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Q about integer multiply

$
0
0

Suppose we have:

      integer(4) x,y

      integer (8) z

      z=x*y

In almost all cases, the result will be wrong, in fact, more than 99.9999 percent of the

time, since the compiler does not understand that the result can be more than 4 bytes.

This wrong result is not detected, since apparently the compiler does not check for an overflow.

At least, not on the INTEL compiler, although in my work at Aerospace and JPL IBM 7094

main frames, it did tell you about the overflow.

so to avoid this, I have to say:

       z=int(x,8)*y

Is there a simpler way around this? Maybe the compiler people should take a serious look at this.

You see the same problem with INTEGER(1) AND INTEGER(2) variables, BTW...........

 

As well as with the ADD operator. seems like an overflow check would be a simple answer,

though it does slow down things. So maybe as an option ?


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>