|
很久以前做的东西,做出来以后一直没想到有什么用…………
[jass]
//=======================取整===========================================
function R2Z takes real IR returns real
return I2R( R2I( IR))
endfunction
//=======================10进制转2进制==================================
function Ten2Two takes integer IInt returns integer
local real TempReal = I2R(IInt)
local string array OInt
local integer indexa = 1
loop
exitwhen TempReal == 0
if TempReal/2 - I2R( R2I (TempReal/2)) != 0 then
set OInt[indexa] = "1"
else
set OInt[indexa] = "0"
endif
set TempReal = I2R( R2I (TempReal/2))
set indexa = indexa + 1
endloop
set OInt[0] = null
loop
exitwhen indexa == 0
set OInt[0] = OInt[0] + OInt[indexa]
set indexa = indexa - 1
endloop
return S2I(OInt[0])
endfunction
//=======================2进制转10进制==================================
function Two2Ten takes integer IInt returns integer
local integer count = 0
local integer OInt = 0
local integer indexa = 1
local integer indexb = 0
loop
exitwhen indexa > StringLength( I2S(IInt))
set indexb = 0
set count = 1
loop
exitwhen indexb > indexa - 1
if indexb == 0 then
set count = 1
else
set count = count * 2
endif
set indexb = indexb + 1
endloop
set count = S2I( SubStringBJ( I2S(IInt), indexa, indexa)) * count
set OInt = OInt + count
set indexa = indexa + 1
endloop
return OInt
endfunction[/jass] |
|