- Joined
- Jul 20, 2018
- Messages
- 177
I made a test in WarCraft 3 1.26a. I filled 2 arrays of reals with the powers of 2 from 0 to -13. The first array was filled by 'hand', and the values of the second were produced by computation of WarCraft 3. In addition, I put a check if the same powers stored in arrays will differ. This check requires the loop-return hack.
If you run the code below, the result of the whole test will be stored in <WarCraft 3 directory>\Test\R2SWPrecision.txt.
Output of the code above.
If you assign to max 13, you will see that array ByHand simply stores incorrect values in cells 10-13.
So, the first problem: Jass sometimes fails to read reals correctly, even if these reals have precise representations in the float. Powers of 2 actually do have.
I converted int32 representations of 'failed' reals to hexes using this converter. Then I converted hexes to floats using this converter. The result is written below.
You may know that R2SW uses mathematical rounding. Therefore, statements below are true.
But you can see from my test what R2SW actually returns for 'failed' values.
Here is the second problem: R2SW sometimes returns strings that are not correct.
Let's summarize:
I want someone to run that code in the latest official patch of WarCraft 3 or in PTR. If the same problems occur, then it is necessary to report them to developers. You can comment the code that uses the loop-return hack, if it is fixed in latest versions.
If you run the code below, the result of the whole test will be stored in <WarCraft 3 directory>\Test\R2SWPrecision.txt.
JASS:
function R2SWPrecision takes nothing returns nothing
local real array ByWar3
local real array ByHand
local integer a = -1
local integer k
local integer max = 9
call PreloadGenClear()
set ByHand[0] = 1.
set ByHand[1] = 0.5
set ByHand[2] = 0.25
set ByHand[3] = 0.125
set ByHand[4] = 0.0625
set ByHand[5] = 0.03125
set ByHand[6] = 0.015625
set ByHand[7] = 0.0078125
set ByHand[8] = 0.00390625
set ByHand[9] = 0.001953125
set ByHand[10] = 0.0009765625 // invalid
set ByHand[11] = 0.00048828125 // invalid
set ByHand[12] = 0.000244140625 // invalid
set ByHand[13] = 0.0001220703125 // invalid
set ByWar3[0] = 1.
set ByWar3[1] = ByWar3[0] / 2.
set ByWar3[2] = ByWar3[1] / 2.
set ByWar3[3] = ByWar3[2] / 2.
set ByWar3[4] = ByWar3[3] / 2.
set ByWar3[5] = ByWar3[4] / 2.
set ByWar3[6] = ByWar3[5] / 2.
set ByWar3[7] = ByWar3[6] / 2.
set ByWar3[8] = ByWar3[7] / 2.
set ByWar3[9] = ByWar3[8] / 2.
set ByWar3[10] = ByWar3[9] / 2.
set ByWar3[11] = ByWar3[10] / 2.
set ByWar3[12] = ByWar3[11] / 2.
set ByWar3[13] = ByWar3[12] / 2.
loop
set k = 0
loop
call Preload("\") 2^(" + I2S(-k) + ") with precision " + I2S(a) + " in ByHand: " + R2SW(ByHand[k], 0, a) + " //")
call Preload("\") 2^(" + I2S(-k) + ") with precision " + I2S(a) + " in ByWar3: " + R2SW(ByWar3[k], 0, a) + " //")
set k = k + 1
exitwhen k > max
endloop
set a = a + 1
exitwhen a > 9
endloop
set k = 0
loop
if ByHand[k] > ByWar3[k] then
call Preload("\") ByHand[" + I2S(k) + "] stores bigger value! //")
call Preload("\") Int32 representation of ByHand[" + I2S(k) + "] is " + I2S(cleanInt(realToIndex(ByHand[k]))) + " //")
call Preload("\") Int32 representation of ByWar3[" + I2S(k) + "] is " + I2S(cleanInt(realToIndex(ByWar3[k]))) + " //")
elseif ByWar3[k] > ByHand[k] then
call Preload("\") ByWar3[" + I2S(k) + "] stores bigger value! //")
call Preload("\") Int32 representation of ByHand[" + I2S(k) + "] is " + I2S(cleanInt(realToIndex(ByHand[k]))) + " //")
call Preload("\") Int32 representation of ByWar3[" + I2S(k) + "] is " + I2S(cleanInt(realToIndex(ByWar3[k]))) + " //")
endif
set k = k + 1
exitwhen k > max
endloop
call PreloadGenEnd("Test\\R2SWPrecision.txt")
endfunction
Output of the code above.
JASS:
function PreloadFiles takes nothing returns nothing
call Preload( "") 2^(0) with precision -1 in ByHand: 1.0 //" )
call Preload( "") 2^(0) with precision -1 in ByWar3: 1.0 //" )
call Preload( "") 2^(-1) with precision -1 in ByHand: 0.5 //" )
call Preload( "") 2^(-1) with precision -1 in ByWar3: 0.5 //" )
call Preload( "") 2^(-2) with precision -1 in ByHand: 0.25 //" )
call Preload( "") 2^(-2) with precision -1 in ByWar3: 0.25 //" )
call Preload( "") 2^(-3) with precision -1 in ByHand: 0.125 //" )
call Preload( "") 2^(-3) with precision -1 in ByWar3: 0.125 //" )
call Preload( "") 2^(-4) with precision -1 in ByHand: 0.0625 //" )
call Preload( "") 2^(-4) with precision -1 in ByWar3: 0.0625 //" )
call Preload( "") 2^(-5) with precision -1 in ByHand: 0.03125 //" )
call Preload( "") 2^(-5) with precision -1 in ByWar3: 0.03125 //" )
call Preload( "") 2^(-6) with precision -1 in ByHand: 0.015625 //" )
call Preload( "") 2^(-6) with precision -1 in ByWar3: 0.015625 //" )
call Preload( "") 2^(-7) with precision -1 in ByHand: 0.007813 //" )
call Preload( "") 2^(-7) with precision -1 in ByWar3: 0.007813 //" )
call Preload( "") 2^(-8) with precision -1 in ByHand: 0.003906 //" )
call Preload( "") 2^(-8) with precision -1 in ByWar3: 0.003906 //" )
call Preload( "") 2^(-9) with precision -1 in ByHand: 0.001953 //" )
call Preload( "") 2^(-9) with precision -1 in ByWar3: 0.001953 //" )
call Preload( "") 2^(0) with precision 0 in ByHand: 1.0 //" )
call Preload( "") 2^(0) with precision 0 in ByWar3: 1.0 //" )
call Preload( "") 2^(-1) with precision 0 in ByHand: 1.0 //" )
call Preload( "") 2^(-1) with precision 0 in ByWar3: 1.0 //" )
call Preload( "") 2^(-2) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-2) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-3) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-3) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-4) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-4) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-5) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-5) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-6) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-6) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-7) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-7) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-8) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-8) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(-9) with precision 0 in ByHand: 0.0 //" )
call Preload( "") 2^(-9) with precision 0 in ByWar3: 0.0 //" )
call Preload( "") 2^(0) with precision 1 in ByHand: 1.0 //" )
call Preload( "") 2^(0) with precision 1 in ByWar3: 1.0 //" )
call Preload( "") 2^(-1) with precision 1 in ByHand: 0.5 //" )
call Preload( "") 2^(-1) with precision 1 in ByWar3: 0.5 //" )
call Preload( "") 2^(-2) with precision 1 in ByHand: 0.3 //" )
call Preload( "") 2^(-2) with precision 1 in ByWar3: 0.3 //" )
call Preload( "") 2^(-3) with precision 1 in ByHand: 0.1 //" )
call Preload( "") 2^(-3) with precision 1 in ByWar3: 0.1 //" )
call Preload( "") 2^(-4) with precision 1 in ByHand: 0.1 //" )
call Preload( "") 2^(-4) with precision 1 in ByWar3: 0.1 //" )
call Preload( "") 2^(-5) with precision 1 in ByHand: 0.0 //" )
call Preload( "") 2^(-5) with precision 1 in ByWar3: 0.0 //" )
call Preload( "") 2^(-6) with precision 1 in ByHand: 0.0 //" )
call Preload( "") 2^(-6) with precision 1 in ByWar3: 0.0 //" )
call Preload( "") 2^(-7) with precision 1 in ByHand: 0.0 //" )
call Preload( "") 2^(-7) with precision 1 in ByWar3: 0.0 //" )
call Preload( "") 2^(-8) with precision 1 in ByHand: 0.0 //" )
call Preload( "") 2^(-8) with precision 1 in ByWar3: 0.0 //" )
call Preload( "") 2^(-9) with precision 1 in ByHand: 0.0 //" )
call Preload( "") 2^(-9) with precision 1 in ByWar3: 0.0 //" )
call Preload( "") 2^(0) with precision 2 in ByHand: 1.00 //" )
call Preload( "") 2^(0) with precision 2 in ByWar3: 1.00 //" )
call Preload( "") 2^(-1) with precision 2 in ByHand: 0.50 //" )
call Preload( "") 2^(-1) with precision 2 in ByWar3: 0.50 //" )
call Preload( "") 2^(-2) with precision 2 in ByHand: 0.25 //" )
call Preload( "") 2^(-2) with precision 2 in ByWar3: 0.25 //" )
call Preload( "") 2^(-3) with precision 2 in ByHand: 0.13 //" )
call Preload( "") 2^(-3) with precision 2 in ByWar3: 0.13 //" )
call Preload( "") 2^(-4) with precision 2 in ByHand: 0.06 //" )
call Preload( "") 2^(-4) with precision 2 in ByWar3: 0.06 //" )
call Preload( "") 2^(-5) with precision 2 in ByHand: 0.03 //" )
call Preload( "") 2^(-5) with precision 2 in ByWar3: 0.03 //" )
call Preload( "") 2^(-6) with precision 2 in ByHand: 0.02 //" )
call Preload( "") 2^(-6) with precision 2 in ByWar3: 0.02 //" )
call Preload( "") 2^(-7) with precision 2 in ByHand: 0.01 //" )
call Preload( "") 2^(-7) with precision 2 in ByWar3: 0.01 //" )
call Preload( "") 2^(-8) with precision 2 in ByHand: 0.00 //" )
call Preload( "") 2^(-8) with precision 2 in ByWar3: 0.00 //" )
call Preload( "") 2^(-9) with precision 2 in ByHand: 0.00 //" )
call Preload( "") 2^(-9) with precision 2 in ByWar3: 0.00 //" )
call Preload( "") 2^(0) with precision 3 in ByHand: 1.000 //" )
call Preload( "") 2^(0) with precision 3 in ByWar3: 1.000 //" )
call Preload( "") 2^(-1) with precision 3 in ByHand: 0.500 //" )
call Preload( "") 2^(-1) with precision 3 in ByWar3: 0.500 //" )
call Preload( "") 2^(-2) with precision 3 in ByHand: 0.250 //" )
call Preload( "") 2^(-2) with precision 3 in ByWar3: 0.250 //" )
call Preload( "") 2^(-3) with precision 3 in ByHand: 0.125 //" )
call Preload( "") 2^(-3) with precision 3 in ByWar3: 0.125 //" )
call Preload( "") 2^(-4) with precision 3 in ByHand: 0.063 //" )
call Preload( "") 2^(-4) with precision 3 in ByWar3: 0.063 //" )
call Preload( "") 2^(-5) with precision 3 in ByHand: 0.031 //" )
call Preload( "") 2^(-5) with precision 3 in ByWar3: 0.031 //" )
call Preload( "") 2^(-6) with precision 3 in ByHand: 0.016 //" )
call Preload( "") 2^(-6) with precision 3 in ByWar3: 0.016 //" )
call Preload( "") 2^(-7) with precision 3 in ByHand: 0.008 //" )
call Preload( "") 2^(-7) with precision 3 in ByWar3: 0.008 //" )
call Preload( "") 2^(-8) with precision 3 in ByHand: 0.004 //" )
call Preload( "") 2^(-8) with precision 3 in ByWar3: 0.004 //" )
call Preload( "") 2^(-9) with precision 3 in ByHand: 0.002 //" )
call Preload( "") 2^(-9) with precision 3 in ByWar3: 0.002 //" )
call Preload( "") 2^(0) with precision 4 in ByHand: 1.0000 //" )
call Preload( "") 2^(0) with precision 4 in ByWar3: 1.0000 //" )
call Preload( "") 2^(-1) with precision 4 in ByHand: 0.5000 //" )
call Preload( "") 2^(-1) with precision 4 in ByWar3: 0.5000 //" )
call Preload( "") 2^(-2) with precision 4 in ByHand: 0.2500 //" )
call Preload( "") 2^(-2) with precision 4 in ByWar3: 0.2500 //" )
call Preload( "") 2^(-3) with precision 4 in ByHand: 0.1250 //" )
call Preload( "") 2^(-3) with precision 4 in ByWar3: 0.1250 //" )
call Preload( "") 2^(-4) with precision 4 in ByHand: 0.0625 //" )
call Preload( "") 2^(-4) with precision 4 in ByWar3: 0.0625 //" )
call Preload( "") 2^(-5) with precision 4 in ByHand: 0.0313 //" )
call Preload( "") 2^(-5) with precision 4 in ByWar3: 0.0313 //" )
call Preload( "") 2^(-6) with precision 4 in ByHand: 0.0156 //" )
call Preload( "") 2^(-6) with precision 4 in ByWar3: 0.0156 //" )
call Preload( "") 2^(-7) with precision 4 in ByHand: 0.0078 //" )
call Preload( "") 2^(-7) with precision 4 in ByWar3: 0.0078 //" )
call Preload( "") 2^(-8) with precision 4 in ByHand: 0.0039 //" )
call Preload( "") 2^(-8) with precision 4 in ByWar3: 0.0039 //" )
call Preload( "") 2^(-9) with precision 4 in ByHand: 0.0020 //" )
call Preload( "") 2^(-9) with precision 4 in ByWar3: 0.0020 //" )
call Preload( "") 2^(0) with precision 5 in ByHand: 1.00000 //" )
call Preload( "") 2^(0) with precision 5 in ByWar3: 1.00000 //" )
call Preload( "") 2^(-1) with precision 5 in ByHand: 0.50000 //" )
call Preload( "") 2^(-1) with precision 5 in ByWar3: 0.50000 //" )
call Preload( "") 2^(-2) with precision 5 in ByHand: 0.25000 //" )
call Preload( "") 2^(-2) with precision 5 in ByWar3: 0.25000 //" )
call Preload( "") 2^(-3) with precision 5 in ByHand: 0.12500 //" )
call Preload( "") 2^(-3) with precision 5 in ByWar3: 0.12500 //" )
call Preload( "") 2^(-4) with precision 5 in ByHand: 0.06250 //" )
call Preload( "") 2^(-4) with precision 5 in ByWar3: 0.06250 //" )
call Preload( "") 2^(-5) with precision 5 in ByHand: 0.03125 //" )
call Preload( "") 2^(-5) with precision 5 in ByWar3: 0.03125 //" )
call Preload( "") 2^(-6) with precision 5 in ByHand: 0.01563 //" )
call Preload( "") 2^(-6) with precision 5 in ByWar3: 0.01563 //" )
call Preload( "") 2^(-7) with precision 5 in ByHand: 0.00781 //" )
call Preload( "") 2^(-7) with precision 5 in ByWar3: 0.00781 //" )
call Preload( "") 2^(-8) with precision 5 in ByHand: 0.00391 //" )
call Preload( "") 2^(-8) with precision 5 in ByWar3: 0.00391 //" )
call Preload( "") 2^(-9) with precision 5 in ByHand: 0.00195 //" )
call Preload( "") 2^(-9) with precision 5 in ByWar3: 0.00195 //" )
call Preload( "") 2^(0) with precision 6 in ByHand: 1.000000 //" )
call Preload( "") 2^(0) with precision 6 in ByWar3: 1.000000 //" )
call Preload( "") 2^(-1) with precision 6 in ByHand: 0.500000 //" )
call Preload( "") 2^(-1) with precision 6 in ByWar3: 0.500000 //" )
call Preload( "") 2^(-2) with precision 6 in ByHand: 0.250000 //" )
call Preload( "") 2^(-2) with precision 6 in ByWar3: 0.250000 //" )
call Preload( "") 2^(-3) with precision 6 in ByHand: 0.125000 //" )
call Preload( "") 2^(-3) with precision 6 in ByWar3: 0.125000 //" )
call Preload( "") 2^(-4) with precision 6 in ByHand: 0.062500 //" )
call Preload( "") 2^(-4) with precision 6 in ByWar3: 0.062500 //" )
call Preload( "") 2^(-5) with precision 6 in ByHand: 0.031250 //" )
call Preload( "") 2^(-5) with precision 6 in ByWar3: 0.031250 //" )
call Preload( "") 2^(-6) with precision 6 in ByHand: 0.015625 //" )
call Preload( "") 2^(-6) with precision 6 in ByWar3: 0.015625 //" )
call Preload( "") 2^(-7) with precision 6 in ByHand: 0.007813 //" )
call Preload( "") 2^(-7) with precision 6 in ByWar3: 0.007813 //" )
call Preload( "") 2^(-8) with precision 6 in ByHand: 0.003906 //" )
call Preload( "") 2^(-8) with precision 6 in ByWar3: 0.003906 //" )
call Preload( "") 2^(-9) with precision 6 in ByHand: 0.001953 //" )
call Preload( "") 2^(-9) with precision 6 in ByWar3: 0.001953 //" )
call Preload( "") 2^(0) with precision 7 in ByHand: 1.0000000 //" )
call Preload( "") 2^(0) with precision 7 in ByWar3: 1.0000000 //" )
call Preload( "") 2^(-1) with precision 7 in ByHand: 0.5000000 //" )
call Preload( "") 2^(-1) with precision 7 in ByWar3: 0.5000000 //" )
call Preload( "") 2^(-2) with precision 7 in ByHand: 0.2500000 //" )
call Preload( "") 2^(-2) with precision 7 in ByWar3: 0.2500000 //" )
call Preload( "") 2^(-3) with precision 7 in ByHand: 0.1250000 //" )
call Preload( "") 2^(-3) with precision 7 in ByWar3: 0.1250000 //" )
call Preload( "") 2^(-4) with precision 7 in ByHand: 0.0625000 //" )
call Preload( "") 2^(-4) with precision 7 in ByWar3: 0.0625000 //" )
call Preload( "") 2^(-5) with precision 7 in ByHand: 0.0312500 //" )
call Preload( "") 2^(-5) with precision 7 in ByWar3: 0.0312500 //" )
call Preload( "") 2^(-6) with precision 7 in ByHand: 0.0156250 //" )
call Preload( "") 2^(-6) with precision 7 in ByWar3: 0.0156250 //" )
call Preload( "") 2^(-7) with precision 7 in ByHand: 0.0078125 //" )
call Preload( "") 2^(-7) with precision 7 in ByWar3: 0.0078125 //" )
call Preload( "") 2^(-8) with precision 7 in ByHand: 0.0039063 //" )
call Preload( "") 2^(-8) with precision 7 in ByWar3: 0.0039063 //" )
call Preload( "") 2^(-9) with precision 7 in ByHand: 0.0019531 //" )
call Preload( "") 2^(-9) with precision 7 in ByWar3: 0.0019531 //" )
call Preload( "") 2^(0) with precision 8 in ByHand: 1.00000000 //" )
call Preload( "") 2^(0) with precision 8 in ByWar3: 1.00000000 //" )
call Preload( "") 2^(-1) with precision 8 in ByHand: 0.50000000 //" )
call Preload( "") 2^(-1) with precision 8 in ByWar3: 0.50000000 //" )
call Preload( "") 2^(-2) with precision 8 in ByHand: 0.25000000 //" )
call Preload( "") 2^(-2) with precision 8 in ByWar3: 0.25000000 //" )
call Preload( "") 2^(-3) with precision 8 in ByHand: 0.12500000 //" )
call Preload( "") 2^(-3) with precision 8 in ByWar3: 0.12500000 //" )
call Preload( "") 2^(-4) with precision 8 in ByHand: 0.06250000 //" )
call Preload( "") 2^(-4) with precision 8 in ByWar3: 0.06250000 //" )
call Preload( "") 2^(-5) with precision 8 in ByHand: 0.03125000 //" )
call Preload( "") 2^(-5) with precision 8 in ByWar3: 0.03125000 //" )
call Preload( "") 2^(-6) with precision 8 in ByHand: 0.01562500 //" )
call Preload( "") 2^(-6) with precision 8 in ByWar3: 0.01562500 //" )
call Preload( "") 2^(-7) with precision 8 in ByHand: 0.00781250 //" )
call Preload( "") 2^(-7) with precision 8 in ByWar3: 0.00781250 //" )
call Preload( "") 2^(-8) with precision 8 in ByHand: 0.00390625 //" )
call Preload( "") 2^(-8) with precision 8 in ByWar3: 0.00390625 //" )
call Preload( "") 2^(-9) with precision 8 in ByHand: 0.00195313 //" )
call Preload( "") 2^(-9) with precision 8 in ByWar3: 0.00195313 //" )
call Preload( "") 2^(0) with precision 9 in ByHand: 1.000000000 //" )
call Preload( "") 2^(0) with precision 9 in ByWar3: 1.000000000 //" )
call Preload( "") 2^(-1) with precision 9 in ByHand: 0.500000000 //" )
call Preload( "") 2^(-1) with precision 9 in ByWar3: 0.500000000 //" )
call Preload( "") 2^(-2) with precision 9 in ByHand: 0.250000000 //" )
call Preload( "") 2^(-2) with precision 9 in ByWar3: 0.250000000 //" )
call Preload( "") 2^(-3) with precision 9 in ByHand: 0.125000000 //" )
call Preload( "") 2^(-3) with precision 9 in ByWar3: 0.125000000 //" )
call Preload( "") 2^(-4) with precision 9 in ByHand: 0.062500000 //" )
call Preload( "") 2^(-4) with precision 9 in ByWar3: 0.062500000 //" )
call Preload( "") 2^(-5) with precision 9 in ByHand: 0.031250002 //" )
call Preload( "") 2^(-5) with precision 9 in ByWar3: 0.031250000 //" )
call Preload( "") 2^(-6) with precision 9 in ByHand: 0.015625000 //" )
call Preload( "") 2^(-6) with precision 9 in ByWar3: 0.015625000 //" )
call Preload( "") 2^(-7) with precision 9 in ByHand: 0.007812500 //" )
call Preload( "") 2^(-7) with precision 9 in ByWar3: 0.007812500 //" )
call Preload( "") 2^(-8) with precision 9 in ByHand: 0.003906250 //" )
call Preload( "") 2^(-8) with precision 9 in ByWar3: 0.003906250 //" )
call Preload( "") 2^(-9) with precision 9 in ByHand: 0.001953125 //" )
call Preload( "") 2^(-9) with precision 9 in ByWar3: 0.001953125 //" )
call Preload( "") ByHand[5] stores bigger value! //" )
call Preload( "") Int32 representation of ByHand[5] is 1023410177 //" )
call Preload( "") Int32 representation of ByWar3[5] is 1023410176 //" )
call Preload( "") ByHand[7] stores bigger value! //" )
call Preload( "") Int32 representation of ByHand[7] is 1006632961 //" )
call Preload( "") Int32 representation of ByWar3[7] is 1006632960 //" )
call PreloadEnd( 31767.1 )
endfunction
If you assign to max 13, you will see that array ByHand simply stores incorrect values in cells 10-13.
So, the first problem: Jass sometimes fails to read reals correctly, even if these reals have precise representations in the float. Powers of 2 actually do have.
I converted int32 representations of 'failed' reals to hexes using this converter. Then I converted hexes to floats using this converter. The result is written below.
JASS:
ByHand[5] actually stores 0.0312500037252902984619140625.
ByWar3[5] stores 0.03125.
ByHand[7] actually stores 0.007812500931322574615478515625.
ByWar3[7] stores 0.0078125.
JASS:
R2SW(ByHand[5], 0, 9) must output 0.031250004.
R2SW(ByHand[7], 0, 9) must output 0.007812501.
JASS:
R2SW(ByHand[5], 0, 9) outputs 0.031250002.
R2SW(ByHand[7], 0, 9) outputs 0.007812500.
Let's summarize:
- Jass sometimes fails to read reals correctly, even if these reals have precise representations in the float.
- R2SW sometimes returns strings that are not correct.
I want someone to run that code in the latest official patch of WarCraft 3 or in PTR. If the same problems occur, then it is necessary to report them to developers. You can comment the code that uses the loop-return hack, if it is fixed in latest versions.