Code: Select all
a := ""
tot := 0
iter := 100
max := 21474893647
loop %iter%
{
random, b, 0, %max%
a .= " "b
tot += b
}
msgbox % "iteratinons: " iter "`nMax:`t" max "`tAverage:`t" tot/iter "`n"a
exitapp
Code: Select all
a := ""
tot := 0
iter := 100
max := 21474893647
loop %iter%
{
random, b, 0, %max%
a .= " "b
tot += b
}
msgbox % "iteratinons: " iter "`nMax:`t" max "`tAverage:`t" tot/iter "`n"a
exitapp
The largest number that can be generated, which can be negative, floating point, or an expression. If omitted, the largest number will be 2147483647 (which is also the largest allowed integer value -- but floating point numbers have no restrictions).
What gives me the idea that c&p is our friendjoefiesta wrote:yeah, thanks... I just noticed my typo (and extra 9 in the number).
Code: Select all
q:: ;overflow
;21474893647 = 0x50000DF4F ;typo
;2147483647 = 0x7FFFFFFF ;correct number
VarSetCapacity(vData, 4, 0)
NumPut(21474893647, &vData, 0, "Int")
MsgBox, % NumGet(&vData, 0, "Int") ;57167
;not quite the right calculation:
MsgBox, % Mod(21474893647, 2147483647) ;57177
;possibly the right calculation (although would give an unsigned integer, not a signed integer):
MsgBox, % Mod(21474893647, (2147483647+1)*2) ;57167
return
its a miscalculation on my part: i subtracted (2^31 - 1) a bunch of times, instead of just 2^31Odlanir wrote:@swagfag : Out of curiosity, how do you get the number 57177 ? Since I ran the Op code ( several time with 10.000.000 iterations ) and the max number for me is 57167.
Users browsing this forum: No registered users and 219 guests