- Joined
- Jul 20, 2009
- Messages
- 835
Hello again. Gonna write a post about JASS bug again.
When I've analyzed SirNikolas's version of FICS, I've found a lulz. Here is the code:
I understand that this is a binary searching.
But can someone explain which sorcery made this line:
It must give an error since the result of the division may be real and I see:
I wonder, how... Bug or a feature?
When I've analyzed SirNikolas's version of FICS, I've found a lulz. Here is the code:
JASS:
function Trig_FICS_BinSearch takes integer id returns integer
local integer first = 0
local integer last = udg_FICS_Length
local integer mid
if id >= udg_FICS_Ids[0] and id <= udg_FICS_Ids[last - 1] then
loop
exitwhen first >= last
set mid = (first + last) / 2
if id <= udg_FICS_Ids[mid] then
set last = mid
else
set first = mid + 1
endif
endloop
if id == udg_FICS_Ids[last] then
return udg_FICS_Num[last]
endif
endif
return 0
endfunction
But can someone explain which sorcery made this line:
set mid = (first + last) / 2
compile? It must give an error since the result of the division may be real and I see:
local integer mid
in the beginning! integer is not real. But / 2
is compiling!I wonder, how... Bug or a feature?