here is one way to do so..
function DeComputeIP(cIP)
local ip1 = floor(cIP/16777216)
local ip2 = floor(mod(cIP,16777216)/65536)
local ip3 = floor(mod(mod(cIP,16777216),65536)/256)
local ip4 = floor(mod(mod(mod(cIP,16777216),65536),256))
return (ip1.."."..ip2.."."..ip3.."."..ip4)
end
What is this good for Chilla ?
mean DeComputeIP
is it the oposite to ComputeIP ?
chilla, wouldn't
function DeComputeIP(cIP)
local i,j
i = mod(cIP,16777216)
j = mod(i,65536)
local ip1 = floor(cIP/16777216)
local ip2 = floor(i/65536)
local ip3 = floor(j/256)
local ip4 = floor(mod(j,256))
return (ip1.."."..ip2.."."..ip3.."."..ip4)
end
be a bit faster??
or maybe
function DeComputeIP(cIP)
local i = mod(cIP,16777216)
local j = mod(i,65536)
return (floor(cIP/16777216).."."..floor(i/65536).."."..floor(j/256).."."..floor(mod(j,256)))
end
not tested, but looks like, it was my first try :p ;)
oh an nightlitch, sure, there is also a ComputeIP func,
function ComputeIP(curIP)
local _,_,a,b,c,d = strfind(curIP, "^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
return a*16777216 + b*65536 + c*256 + d
end
That I know. But nice. Maybe start playing with this in my new IP-NXS-RANGER. Without checking your LIS.
know you have it there. have seen the "ranges"... :-)
yeeaa, tell me when your done.
Will then add it to IP.BATTLE :)
Well I already have one created.
But I don't think is so fast Or It could be.
Can post it l8r.
I think this one can be quite handy if you wanted to precompute the ip range and some times want to check them..
How about:
function Int64ToIPString(iIP)
local sRet = "";
for j = 0, j < 4, 1 do
if( j ~= 0) then sRet = "." .. sRet; end
sRet = mod(iIP, 256) .. sRet;
iIP = floor(iIP / 256);
end
return sRet;
end
-NotRabidWombat
Quite nice solution, but i don't beleve that is would be faster ;)
Division takes a while if you use really big numbers. And you push more variables on the stack. Someone should do a time comparison and then the best one is accepted.
I admit I can make this one REALLY fast if I had the bitwise functions of Lua 5.0.
-NotRabidWombat
It wouldn't hurt if ptaczek did change over from lua 4.0 to 5.0 imho, but i think it is more intresting to get the new betas out....