The variable in the for loop is an integer sequence, and so eventually you do this: y=as.integer(60000).as.integer(60000)Warning message:In as.integer(60000). as.integer(60000): NAs produced by integer overflowwhereas in the while loop you are creating a floating point number.Its also the reason these things are different: seq(0,2,1)1 0 1 2 seq(0,2)1 0 1 2Don't believe me? identical(seq(0,2),seq(0,2,1))1 FALSEbecause: is.integer(seq(0,2))1 TRUE is.integer(seq(0,2,1))1 FALSE.
![Alternative Alternative](/uploads/1/2/5/4/125421657/473781283.png)
@Alex (not Brown): an integer is a binary representation in 32bits. So the maximum range is 2^32, or -2e9, +2e9.
Oct 25, 2017 - These are part of the for loop family. In R for loops usually are constructed as such: for(items in listofitems) results. Using loops in R is very handy, but you can write more efficient code if you loop not over the values but over the indices. To do so, you replace the middle section in the function with the following code.
A floating point uses the 32 bits different: it saves a number of bits for the digits (where the decimal is after the first digit), and another set of bits for the power. Obviously this makes the range very much larger.
This is general computing knowledge by the way, apart from some small details this system is the same in every computer language / application.–Nov 17 '10 at 13:31.