Earl F Glynn wrote: > > > 2-byte (16 bit) signed integers would have a range from -32768 to > +37267. So, it looks like you may be using 2-byte integers and 46,300 > would definitely cause an overflow with 16-bit integers. > > I haven't used Fortran for a long time, but there could be a compiler > switch that forces all 2-byte integers, or a specific declaration that > says I, J, N, IOFFSET are only 2-byte (16-bit) integers. > > I'm guess, but you might try a specification like > > INTEGER*4 I, J, N, IOFFSET > > assuming INTEGER*4 is legal with your Fortran compiler: >
The overflow is not caused by 16 bits integers. I'm quite sure the OP is using 32 bit integers. The overflow is caused by the multiplication N*(i-1) and/or i*(i+1). In Fortran there's not much you can do about this unless your compiler supports larger integers. A pity that fortran doesn't have a posint. Either your solution with doubles or a small C function looks like the way out. Berend -- View this message in context: http://r.789695.n4.nabble.com/Fortran-and-long-integers-tp3263054p3263605.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.