- Joined
- Nov 20, 2011
- Messages
- 202
Up to now it was not possible to cast reals to int and back without loosing accuracy and performance
But muzzel and i found some tricky way to do this:
Important: Ignore compiling errors, wc3 will accept it nevertheless!!!
But muzzel and i found some tricky way to do this:
JASS:
function realToIndex takes real r returns integer
return r
endfunction
function cleanInt takes integer i returns integer
return i
endfunction
function indexToReal takes integer i returns real
return i
endfunction
function cleanReal takes real r returns real
return r
endfunction
function testCast takes nothing returns nothing
local integer i = cleanInt(realToIndex(123.456))
local real r = cleanReal(indexToReal(i))
call BJDebugMsg(R2S(r)) //prints 123.456
endfunction
Important: Ignore compiling errors, wc3 will accept it nevertheless!!!
Last edited: